]> err.no Git - linux-2.6/commitdiff
[netdrvr] depca: handle platform_device_add() failure
authorAndrea Righi <a.righi@cineca.it>
Tue, 24 Apr 2007 16:40:57 +0000 (12:40 -0400)
committerJeff Garzik <jeff@garzik.org>
Tue, 24 Apr 2007 16:40:57 +0000 (12:40 -0400)
The following patch fixes a kernel bug in depca_platform_probe().

We don't use a dynamic pointer for pldev->dev.platform_data, so it seems
that the correct way to proceed if platform_device_add(pldev) fails is
to explicitly set the pldev->dev.platform_data pointer to NULL, before
calling the platform_device_put(pldev), or it will be kfree'ed by
platform_device_release().

Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/depca.c

index 5113eef755b98cbc5104d9e4a4aff493b6a5be67..f3807aaf10aa59d01285a51eaf7e018fece1747f 100644 (file)
@@ -1491,8 +1491,9 @@ static void __init depca_platform_probe (void)
                depca_io_ports[i].device = pldev;
 
                if (platform_device_add(pldev)) {
-                       platform_device_put(pldev);
                        depca_io_ports[i].device = NULL;
+                       pldev->dev.platform_data = NULL;
+                       platform_device_put(pldev);
                        continue;
                }