Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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@visionengravers.com>
Reported-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

H Hartley Sweeten and committed by
David Woodhouse
1ca5d2f0 fed457a8

+5 -2
+5 -2
drivers/mtd/maps/physmap.c
··· 264 264 265 265 err = platform_driver_register(&physmap_flash_driver); 266 266 #ifdef CONFIG_MTD_PHYSMAP_COMPAT 267 - if (err == 0) 268 - platform_device_register(&physmap_flash); 267 + if (err == 0) { 268 + err = platform_device_register(&physmap_flash); 269 + if (err) 270 + platform_driver_unregister(&physmap_flash_driver); 271 + } 269 272 #endif 270 273 271 274 return err;