[PATCH 2.6] Fix OOPS in device_platform_unregister

From: Dmitry Torokhov
Date: Sat Jul 10 2004 - 22:15:03 EST


Hi,

The following patch should fix the oops reported by Denis. We can safely
move call to device_unregister as the release fucntion is not guaranteed
to be called immediately and therefore should not access resources anyway.

--
Dmitry


===================================================================


ChangeSet@xxxxxx, 2004-07-10 22:08:01-05:00, dtor_core@xxxxxxxxxxxxx
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 <dtor@xxxxxxx>



platform.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)


===================================================================



diff -Nru a/drivers/base/platform.c b/drivers/base/platform.c
--- a/drivers/base/platform.c 2004-07-10 22:09:10 -05:00
+++ b/drivers/base/platform.c 2004-07-10 22:09:10 -05:00
@@ -146,13 +146,13 @@
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);
}
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/