From: Dmitry Torokhov 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: Andrew Morton --- 25-akpm/drivers/base/platform.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff -puN drivers/base/platform.c~fix-oops-in-device_platform_unregister drivers/base/platform.c --- 25/drivers/base/platform.c~fix-oops-in-device_platform_unregister 2004-07-11 21:43:59.874503656 -0700 +++ 25-akpm/drivers/base/platform.c 2004-07-11 21:43:59.879502896 -0700 @@ -146,13 +146,13 @@ void platform_device_unregister(struct p 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); } } _