]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Driver core: Fix OOPS in device_platform_unregister
authorDmitry Torokhov <dtor_core@ameritech.net>
Wed, 14 Jul 2004 09:09:44 +0000 (02:09 -0700)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 14 Jul 2004 09:09:44 +0000 (02:09 -0700)
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@mail.ru>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/base/platform.c

index 715bb2397576b399f433b59af53279f8214ada60..9f285ed4e29fcd65af8ea14af706c18af6a5d9da 100644 (file)
@@ -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);
        }
 }