diff options
| author | Andrew Morton <akpm@osdl.org> | 2004-02-18 04:46:43 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-02-18 04:46:43 -0800 |
| commit | 685eba2c0d2315728eb0d514998f7c669650afc4 (patch) | |
| tree | 83b4e5585e1ab54c88cc900e1dc05a18ee5e59f3 /drivers/block/loop.c | |
| parent | 56b63427a7aa8acad19e0651c1489f73f3d01d8d (diff) | |
[PATCH] loop.c doesn't fail init gracefully
From: BlaisorBlade <blaisorblade_spam@yahoo.it>
loop_init doesn't fail gracefully for two reasons:
1) If initialization of loop driver fails, we have an call to
devfs_add("loop") without any devfs_remove; I add that.
2) On lwn.net 2.6 kernel docs, Jonathan Corbet says: "If you are calling
add_disk() in your driver initialization routine, you should not fail
the initialization process after the first call."
So I make loop.c conform to this request by moving add_disk after all
memory allocations.
Diffstat (limited to 'drivers/block/loop.c')
| -rw-r--r-- | drivers/block/loop.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 2977d00dfd3b..2aa58afe776c 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1027,14 +1027,18 @@ int __init loop_init(void) sprintf(disk->devfs_name, "loop/%d", i); disk->private_data = lo; disk->queue = lo->lo_queue; - add_disk(disk); } + + /* We cannot fail after we call this, so another loop!*/ + for (i = 0; i < max_loop; i++) + add_disk(disks[i]); printk(KERN_INFO "loop: loaded (max %d devices)\n", max_loop); return 0; out_mem4: while (i--) blk_put_queue(loop_dev[i].lo_queue); + devfs_remove("loop"); i = max_loop; out_mem3: while (i--) |
