From: BlaisorBlade 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. --- 25-akpm/drivers/block/loop.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletion(-) diff -puN drivers/block/loop.c~loop-init-fix drivers/block/loop.c --- 25/drivers/block/loop.c~loop-init-fix Wed Jan 14 14:44:15 2004 +++ 25-akpm/drivers/block/loop.c Wed Jan 14 14:44:15 2004 @@ -1026,14 +1026,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--) _