mtd/maps/physmap: catch failure to register MTD_PHYSMAP_COMPAT device

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed Apr 21 05:59:02 EDT 2010


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=1ca5d2f0196cfca678086fa6f88eec4f9d0307ee
Commit:     1ca5d2f0196cfca678086fa6f88eec4f9d0307ee
Parent:     fed457a83611182f5a2e049cce02f8f4e1b65644
Author:     H Hartley Sweeten <hartleys at visionengravers.com>
AuthorDate: Fri Apr 2 17:46:30 2010 -0500
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Tue Apr 20 08:53:52 2010 +0100

    mtd/maps/physmap: catch failure to register MTD_PHYSMAP_COMPAT device
    
    If the default Kconfig values are used with MTD_PHYSMAP_COMPAT you end
    up with a resource where end < start.  This causes __request_resource to
    return a conflict which then returns an -EBUSY error code.  The current
    physmap.c code just assumes that the platfom_device_register will always
    succeed.
    
    Catch this failure during the physmap_init and propogate the error.
    
    Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
    Reported-by: Randy Dunlap <randy.dunlap at oracle.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/maps/physmap.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index d9603f7..426461a 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -264,8 +264,11 @@ static int __init physmap_init(void)
 
 	err = platform_driver_register(&physmap_flash_driver);
 #ifdef CONFIG_MTD_PHYSMAP_COMPAT
-	if (err == 0)
-		platform_device_register(&physmap_flash);
+	if (err == 0) {
+		err = platform_device_register(&physmap_flash);
+		if (err)
+			platform_driver_unregister(&physmap_flash_driver);
+	}
 #endif
 
 	return err;



More information about the linux-mtd-cvs mailing list