From b6c1cfc66e1baff2bd698296dfe25d7edf21c30b Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 14 Jul 2004 02:09:44 -0700 Subject: [PATCH] [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: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/base/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 715bb2397576b..9f285ed4e29fc 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -146,13 +146,13 @@ void platform_device_unregister(struct platform_device * pdev) int i; if (pdev) { - device_unregister(&pdev->dev); - for (i = 0; i < pdev->num_resources; i++) { struct resource *r = &pdev->resource[i]; if (r->flags & (IORESOURCE_MEM|IORESOURCE_IO)) release_resource(r); } + + device_unregister(&pdev->dev); } } -- 2.53.0