Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+36 -22
+12 -5
drivers/ata/ahci.c
··· 1975 1975 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map)); 1976 1976 1977 1977 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); 1978 - if (!host) 1979 - return -ENOMEM; 1978 + if (!host) { 1979 + rc = -ENOMEM; 1980 + goto err_rm_sysfs_file; 1981 + } 1980 1982 host->private_data = hpriv; 1981 1983 1982 1984 if (ahci_init_msi(pdev, n_ports, hpriv) < 0) { ··· 2033 2031 /* initialize adapter */ 2034 2032 rc = ahci_configure_dma_masks(pdev, hpriv); 2035 2033 if (rc) 2036 - return rc; 2034 + goto err_rm_sysfs_file; 2037 2035 2038 2036 rc = ahci_pci_reset_controller(host); 2039 2037 if (rc) 2040 - return rc; 2038 + goto err_rm_sysfs_file; 2041 2039 2042 2040 ahci_pci_init_controller(host); 2043 2041 ahci_pci_print_info(host); ··· 2046 2044 2047 2045 rc = ahci_host_activate(host, &ahci_sht); 2048 2046 if (rc) 2049 - return rc; 2047 + goto err_rm_sysfs_file; 2050 2048 2051 2049 pm_runtime_put_noidle(&pdev->dev); 2052 2050 return 0; 2051 + 2052 + err_rm_sysfs_file: 2053 + sysfs_remove_file_from_group(&pdev->dev.kobj, 2054 + &dev_attr_remapped_nvme.attr, NULL); 2055 + return rc; 2053 2056 } 2054 2057 2055 2058 static void ahci_shutdown_one(struct pci_dev *pdev)
+19 -13
drivers/ata/libata-core.c
··· 4137 4137 { "PIONEER BD-RW BDR-205", NULL, ATA_HORKAGE_NOLPM }, 4138 4138 4139 4139 /* Crucial devices with broken LPM support */ 4140 - { "CT500BX100SSD1", NULL, ATA_HORKAGE_NOLPM }, 4141 - { "CT240BX500SSD1", NULL, ATA_HORKAGE_NOLPM }, 4140 + { "CT*0BX*00SSD1", NULL, ATA_HORKAGE_NOLPM }, 4142 4141 4143 4142 /* 512GB MX100 with MU01 firmware has both queued TRIM and LPM issues */ 4144 4143 { "Crucial_CT512MX100*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM | ··· 5489 5490 return ap; 5490 5491 } 5491 5492 5493 + void ata_port_free(struct ata_port *ap) 5494 + { 5495 + if (!ap) 5496 + return; 5497 + 5498 + kfree(ap->pmp_link); 5499 + kfree(ap->slave_link); 5500 + kfree(ap->ncq_sense_buf); 5501 + kfree(ap); 5502 + } 5503 + EXPORT_SYMBOL_GPL(ata_port_free); 5504 + 5492 5505 static void ata_devres_release(struct device *gendev, void *res) 5493 5506 { 5494 5507 struct ata_host *host = dev_get_drvdata(gendev); ··· 5527 5516 int i; 5528 5517 5529 5518 for (i = 0; i < host->n_ports; i++) { 5530 - struct ata_port *ap = host->ports[i]; 5531 - 5532 - kfree(ap->pmp_link); 5533 - kfree(ap->slave_link); 5534 - kfree(ap->ncq_sense_buf); 5535 - kfree(ap); 5519 + ata_port_free(host->ports[i]); 5536 5520 host->ports[i] = NULL; 5537 5521 } 5538 5522 kfree(host); ··· 5577 5571 if (!host) 5578 5572 return NULL; 5579 5573 5580 - if (!devres_open_group(dev, NULL, GFP_KERNEL)) 5581 - goto err_free; 5574 + if (!devres_open_group(dev, NULL, GFP_KERNEL)) { 5575 + kfree(host); 5576 + return NULL; 5577 + } 5582 5578 5583 5579 dr = devres_alloc(ata_devres_release, 0, GFP_KERNEL); 5584 5580 if (!dr) ··· 5612 5604 5613 5605 err_out: 5614 5606 devres_release_group(dev, NULL); 5615 - err_free: 5616 - kfree(host); 5617 5607 return NULL; 5618 5608 } 5619 5609 EXPORT_SYMBOL_GPL(ata_host_alloc); ··· 5910 5904 * allocation time. 5911 5905 */ 5912 5906 for (i = host->n_ports; host->ports[i]; i++) 5913 - kfree(host->ports[i]); 5907 + ata_port_free(host->ports[i]); 5914 5908 5915 5909 /* give ports names and add SCSI hosts */ 5916 5910 for (i = 0; i < host->n_ports; i++) {
+3 -3
drivers/scsi/libsas/sas_ata.c
··· 610 610 611 611 rc = ata_sas_tport_add(ata_host->dev, ap); 612 612 if (rc) 613 - goto destroy_port; 613 + goto free_port; 614 614 615 615 found_dev->sata_dev.ata_host = ata_host; 616 616 found_dev->sata_dev.ap = ap; 617 617 618 618 return 0; 619 619 620 - destroy_port: 621 - kfree(ap); 620 + free_port: 621 + ata_port_free(ap); 622 622 free_host: 623 623 ata_host_put(ata_host); 624 624 return rc;
+1 -1
drivers/scsi/libsas/sas_discover.c
··· 301 301 302 302 if (dev_is_sata(dev) && dev->sata_dev.ap) { 303 303 ata_sas_tport_delete(dev->sata_dev.ap); 304 - kfree(dev->sata_dev.ap); 304 + ata_port_free(dev->sata_dev.ap); 305 305 ata_host_put(dev->sata_dev.ata_host); 306 306 dev->sata_dev.ata_host = NULL; 307 307 dev->sata_dev.ap = NULL;
+1
include/linux/libata.h
··· 1249 1249 extern struct ata_port *ata_sas_port_alloc(struct ata_host *, 1250 1250 struct ata_port_info *, struct Scsi_Host *); 1251 1251 extern void ata_port_probe(struct ata_port *ap); 1252 + extern void ata_port_free(struct ata_port *ap); 1252 1253 extern int ata_sas_tport_add(struct device *parent, struct ata_port *ap); 1253 1254 extern void ata_sas_tport_delete(struct ata_port *ap); 1254 1255 int ata_sas_device_configure(struct scsi_device *sdev, struct queue_limits *lim,