Commit b6c1cfc6 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Greg Kroah-Hartman

[PATCH] Driver core: Fix OOPS in device_platform_unregister

Driver core: platform_device_unregister should release resources first
             and only then call device_unregister, otherwise if there
             are no more references to the device it will be freed and
             the fucntion will try to access freed memory.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 2e4d27c4
...@@ -146,13 +146,13 @@ void platform_device_unregister(struct platform_device * pdev) ...@@ -146,13 +146,13 @@ void platform_device_unregister(struct platform_device * pdev)
int i; int i;
if (pdev) { if (pdev) {
device_unregister(&pdev->dev);
for (i = 0; i < pdev->num_resources; i++) { for (i = 0; i < pdev->num_resources; i++) {
struct resource *r = &pdev->resource[i]; struct resource *r = &pdev->resource[i];
if (r->flags & (IORESOURCE_MEM|IORESOURCE_IO)) if (r->flags & (IORESOURCE_MEM|IORESOURCE_IO))
release_resource(r); release_resource(r);
} }
device_unregister(&pdev->dev);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment