Skip to contentSkip to conversation

USB: chipidea: fix use after free bug

PATCH In review Lothar Waßmann 2 participants 2 messages Nov 22, 2012 – Nov 23, 2012

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

PATCH 1/1 USB: chipidea: fix use after free bug

The pointer to a platform_device struct must not be dereferenced after the device has been unregistered.

This bug produces a crash when unloading the ci13xxx kernel module compiled with CONFIG_PAGE_POISONING enabled.

---
 drivers/usb/chipidea/core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/usb/chipidea/core.c +2 -1
index f69d029..b726c49 100644
@@ -385,8 +385,9 @@ EXPORT_SYMBOL_GPL(ci13xxx_add_device);
 
 void ci13xxx_remove_device(struct platform_device *pdev)
 {
+	int id = pdev->id;
 	platform_device_unregister(pdev);
-	ida_simple_remove(&ci_ida, pdev->id);
+	ida_simple_remove(&ci_ida, id);
 }
 EXPORT_SYMBOL_GPL(ci13xxx_remove_device);
 
Signature · 1 line
1.7.2.5
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Lothar Waßmann

The pointer to a platform_device struct must not be dereferenced after the device has been unregistered.

This bug produces a crash when unloading the ci13xxx kernel module compiled with CONFIG_PAGE_POISONING enabled.

Good one, thanks.

Greg, this is -stable material, applicable starting from v3.6.

Quoted 21 lines
---
 drivers/usb/chipidea/core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/usb/chipidea/core.c +2 -1
index f69d029..b726c49 100644
@@ -385,8 +385,9 @@ EXPORT_SYMBOL_GPL(ci13xxx_add_device);
 
 void ci13xxx_remove_device(struct platform_device *pdev)
 {
+	int id = pdev->id;
 	platform_device_unregister(pdev);
-	ida_simple_remove(&ci_ida, pdev->id);
+	ida_simple_remove(&ci_ida, id);
 }
 EXPORT_SYMBOL_GPL(ci13xxx_remove_device);
 
Signature · 1 line
1.7.2.5