ata fixes for 6.10-rc6
- Add NOLPM quirk for for all Crucial BX SSD1 models. Considering that we now have had bug reports for 3 different BX SSD1 variants from Crucial with the same product name, make the quirk more inclusive, to catch more device models from the same generation. - Fix a trivial null pointer dereference in the error path for ata_host_release(). - Create a ata_port_free(), so that we don't miss freeing ata_port struct members when freeing a struct ata_port. - Fix a trivial double free in the error path for ata_host_alloc(). - Ensure that we remove the libata "remapped NVMe device count" sysfs entry on .probe() error. -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRN+ES/c4tHlMch3DzJZDGjmcZNcgUCZoHMzwAKCRDJZDGjmcZN cj4wAP4nHi3Jr/ezwrIahwMGXV/VSlUhxOakj3OADdHe5spIogD/SrR8Uz7/m5QC sMF0Rd2L7tfrQSDdJ/MztBi7cVprtQo= =lnku -----END PGP SIGNATURE----- Merge tag 'ata-6.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux Pull ata fixes from Niklas Cassel: - Add NOLPM quirk for for all Crucial BX SSD1 models. Considering that we now have had bug reports for 3 different BX SSD1 variants from Crucial with the same product name, make the quirk more inclusive, to catch more device models from the same generation. - Fix a trivial NULL pointer dereference in the error path for ata_host_release(). - Create a ata_port_free(), so that we don't miss freeing ata_port struct members when freeing a struct ata_port. - Fix a trivial double free in the error path for ata_host_alloc(). - Ensure that we remove the libata "remapped NVMe device count" sysfs entry on .probe() error. * tag 'ata-6.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux: ata: ahci: Clean up sysfs file on error ata: libata-core: Fix double free on error ata,scsi: libata-core: Do not leak memory for ata_port struct members ata: libata-core: Fix null pointer dereference on error ata: libata-core: Add ATA_HORKAGE_NOLPM for all Crucial BX SSD1 models
This commit is contained in:
commit
aca7c377d8
@ -1975,8 +1975,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
|
||||
|
||||
host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
|
||||
if (!host)
|
||||
return -ENOMEM;
|
||||
if (!host) {
|
||||
rc = -ENOMEM;
|
||||
goto err_rm_sysfs_file;
|
||||
}
|
||||
host->private_data = hpriv;
|
||||
|
||||
if (ahci_init_msi(pdev, n_ports, hpriv) < 0) {
|
||||
@ -2031,11 +2033,11 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
/* initialize adapter */
|
||||
rc = ahci_configure_dma_masks(pdev, hpriv);
|
||||
if (rc)
|
||||
return rc;
|
||||
goto err_rm_sysfs_file;
|
||||
|
||||
rc = ahci_pci_reset_controller(host);
|
||||
if (rc)
|
||||
return rc;
|
||||
goto err_rm_sysfs_file;
|
||||
|
||||
ahci_pci_init_controller(host);
|
||||
ahci_pci_print_info(host);
|
||||
@ -2044,10 +2046,15 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
||||
rc = ahci_host_activate(host, &ahci_sht);
|
||||
if (rc)
|
||||
return rc;
|
||||
goto err_rm_sysfs_file;
|
||||
|
||||
pm_runtime_put_noidle(&pdev->dev);
|
||||
return 0;
|
||||
|
||||
err_rm_sysfs_file:
|
||||
sysfs_remove_file_from_group(&pdev->dev.kobj,
|
||||
&dev_attr_remapped_nvme.attr, NULL);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void ahci_shutdown_one(struct pci_dev *pdev)
|
||||
|
@ -4137,8 +4137,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
|
||||
{ "PIONEER BD-RW BDR-205", NULL, ATA_HORKAGE_NOLPM },
|
||||
|
||||
/* Crucial devices with broken LPM support */
|
||||
{ "CT500BX100SSD1", NULL, ATA_HORKAGE_NOLPM },
|
||||
{ "CT240BX500SSD1", NULL, ATA_HORKAGE_NOLPM },
|
||||
{ "CT*0BX*00SSD1", NULL, ATA_HORKAGE_NOLPM },
|
||||
|
||||
/* 512GB MX100 with MU01 firmware has both queued TRIM and LPM issues */
|
||||
{ "Crucial_CT512MX100*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM |
|
||||
@ -5490,6 +5489,18 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
|
||||
return ap;
|
||||
}
|
||||
|
||||
void ata_port_free(struct ata_port *ap)
|
||||
{
|
||||
if (!ap)
|
||||
return;
|
||||
|
||||
kfree(ap->pmp_link);
|
||||
kfree(ap->slave_link);
|
||||
kfree(ap->ncq_sense_buf);
|
||||
kfree(ap);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ata_port_free);
|
||||
|
||||
static void ata_devres_release(struct device *gendev, void *res)
|
||||
{
|
||||
struct ata_host *host = dev_get_drvdata(gendev);
|
||||
@ -5516,12 +5527,7 @@ static void ata_host_release(struct kref *kref)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < host->n_ports; i++) {
|
||||
struct ata_port *ap = host->ports[i];
|
||||
|
||||
kfree(ap->pmp_link);
|
||||
kfree(ap->slave_link);
|
||||
kfree(ap->ncq_sense_buf);
|
||||
kfree(ap);
|
||||
ata_port_free(host->ports[i]);
|
||||
host->ports[i] = NULL;
|
||||
}
|
||||
kfree(host);
|
||||
@ -5571,8 +5577,10 @@ struct ata_host *ata_host_alloc(struct device *dev, int max_ports)
|
||||
if (!host)
|
||||
return NULL;
|
||||
|
||||
if (!devres_open_group(dev, NULL, GFP_KERNEL))
|
||||
goto err_free;
|
||||
if (!devres_open_group(dev, NULL, GFP_KERNEL)) {
|
||||
kfree(host);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dr = devres_alloc(ata_devres_release, 0, GFP_KERNEL);
|
||||
if (!dr)
|
||||
@ -5604,8 +5612,6 @@ struct ata_host *ata_host_alloc(struct device *dev, int max_ports)
|
||||
|
||||
err_out:
|
||||
devres_release_group(dev, NULL);
|
||||
err_free:
|
||||
kfree(host);
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ata_host_alloc);
|
||||
@ -5904,7 +5910,7 @@ int ata_host_register(struct ata_host *host, const struct scsi_host_template *sh
|
||||
* allocation time.
|
||||
*/
|
||||
for (i = host->n_ports; host->ports[i]; i++)
|
||||
kfree(host->ports[i]);
|
||||
ata_port_free(host->ports[i]);
|
||||
|
||||
/* give ports names and add SCSI hosts */
|
||||
for (i = 0; i < host->n_ports; i++) {
|
||||
|
@ -610,15 +610,15 @@ int sas_ata_init(struct domain_device *found_dev)
|
||||
|
||||
rc = ata_sas_tport_add(ata_host->dev, ap);
|
||||
if (rc)
|
||||
goto destroy_port;
|
||||
goto free_port;
|
||||
|
||||
found_dev->sata_dev.ata_host = ata_host;
|
||||
found_dev->sata_dev.ap = ap;
|
||||
|
||||
return 0;
|
||||
|
||||
destroy_port:
|
||||
kfree(ap);
|
||||
free_port:
|
||||
ata_port_free(ap);
|
||||
free_host:
|
||||
ata_host_put(ata_host);
|
||||
return rc;
|
||||
|
@ -301,7 +301,7 @@ void sas_free_device(struct kref *kref)
|
||||
|
||||
if (dev_is_sata(dev) && dev->sata_dev.ap) {
|
||||
ata_sas_tport_delete(dev->sata_dev.ap);
|
||||
kfree(dev->sata_dev.ap);
|
||||
ata_port_free(dev->sata_dev.ap);
|
||||
ata_host_put(dev->sata_dev.ata_host);
|
||||
dev->sata_dev.ata_host = NULL;
|
||||
dev->sata_dev.ap = NULL;
|
||||
|
@ -1249,6 +1249,7 @@ extern int ata_slave_link_init(struct ata_port *ap);
|
||||
extern struct ata_port *ata_sas_port_alloc(struct ata_host *,
|
||||
struct ata_port_info *, struct Scsi_Host *);
|
||||
extern void ata_port_probe(struct ata_port *ap);
|
||||
extern void ata_port_free(struct ata_port *ap);
|
||||
extern int ata_sas_tport_add(struct device *parent, struct ata_port *ap);
|
||||
extern void ata_sas_tport_delete(struct ata_port *ap);
|
||||
int ata_sas_device_configure(struct scsi_device *sdev, struct queue_limits *lim,
|
||||
|
Loading…
Reference in New Issue
Block a user