Skip to contentSkip to conversation

mtd: maps: l440gx: Fix double put of the PM device in init_l440gx()

PATCH Applied Wentao Liang 2 participants 2 messages Sep 17 – Sep 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: maps: l440gx: Fix double put of the PM device in init_l440gx()

The PIIX4 PM device reference taken with pci_get_device() is dropped again before the iobase resource is allocated. If pci_assign_resource() fails, the error path calls pci_dev_put() on pm_dev a second time, releasing a reference that is no longer owned and underflowing the reference count.

Remove the extra pci_dev_put().

Fixes dd8e9ed6ed54 ("[MTD] Switch to pci_get_device and do ref counting")
---
 drivers/mtd/maps/l440gx.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/maps/l440gx.c +0 -1
index 85cd273ce065..1df5ea5fafca 100644
@@ -110,7 +110,6 @@ static int __init init_l440gx(void)
 
 		/* Allocate the resource region */
 		if (pci_assign_resource(pm_dev, PIIXE_IOBASE_RESOURCE) != 0) {
-			pci_dev_put(pm_dev);
 			printk(KERN_WARNING "Could not allocate pm iobase resource\n");
 			iounmap(l440gx_map.virt);
 			return -ENXIO;
Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
maintainer Applied
#1 lore raw
Quoted 9 lines · Wentao Liang

The PIIX4 PM device reference taken with pci_get_device() is dropped again before the iobase resource is allocated. If pci_assign_resource() fails, the error path calls pci_dev_put() on pm_dev a second time, releasing a reference that is no longer owned and underflowing the reference count.

Remove the extra pci_dev_put().

[...]

Applied to mtd/next, thanks!

[1/1] mtd: maps: l440gx: Fix double put of the PM device in init_l440gx()

      commit: e6ca524ee5b2705be30ea19ce2e55122d9f9ed8f

Patche(s) should be available on mtd/linux.git and will be part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl