diff options
author | Alex Elder <elder@dreamhost.com> | 2012-02-07 12:03:36 -0600 |
---|---|---|
committer | Alex Elder <elder@dreamhost.com> | 2012-03-22 10:47:50 -0500 |
commit | fed4c143ba8f08c8bddfdc7c69738e691a06d565 (patch) | |
tree | 2c4e649eaa7ea7a73fa29d603c019d7df7fa287a /drivers/block | |
parent | 7ef3214af220515b8fe223ec92ec017d2e5607a7 (diff) | |
download | linux-fed4c143ba8f08c8bddfdc7c69738e691a06d565.tar.gz linux-fed4c143ba8f08c8bddfdc7c69738e691a06d565.tar.bz2 linux-fed4c143ba8f08c8bddfdc7c69738e691a06d565.zip |
rbd: fix module sysfs setup/teardown code
Once rbd_bus_type is registered, it allows an "add" operation via
the /sys/bus/rbd/add bus attribute, and adding a new rbd device that
way establishes a connection between the device and rbd_root_dev.
But rbd_root_dev is not registered until after the rbd_bus_type
registration is complete. This could (in principle anyway) result
in an invalid state.
Since rbd_root_dev has no tie to rbd_bus_type we can reorder these
two initializations and never be faced with this scenario.
In addition, unregister the device in the event the bus registration
fails at module init time.
Signed-off-by: Alex Elder <elder@dreamhost.com>
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/rbd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 641f09898e19..b0f6812f8f99 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2564,19 +2564,21 @@ static int rbd_sysfs_init(void) { int ret; - ret = bus_register(&rbd_bus_type); + ret = device_register(&rbd_root_dev); if (ret < 0) return ret; - ret = device_register(&rbd_root_dev); + ret = bus_register(&rbd_bus_type); + if (ret < 0) + device_unregister(&rbd_root_dev); return ret; } static void rbd_sysfs_cleanup(void) { - device_unregister(&rbd_root_dev); bus_unregister(&rbd_bus_type); + device_unregister(&rbd_root_dev); } int __init rbd_init(void) |