diff options
Diffstat (limited to 'drivers/block/loop.c')
-rw-r--r-- | drivers/block/loop.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index e2fc4b6734cf..5526eadb6592 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -1399,6 +1399,11 @@ static struct loop_device *loop_init_one(int i) | |||
1399 | struct loop_device *lo; | 1399 | struct loop_device *lo; |
1400 | struct gendisk *disk; | 1400 | struct gendisk *disk; |
1401 | 1401 | ||
1402 | list_for_each_entry(lo, &loop_devices, lo_list) { | ||
1403 | if (lo->lo_number == i) | ||
1404 | return lo; | ||
1405 | } | ||
1406 | |||
1402 | lo = kzalloc(sizeof(*lo), GFP_KERNEL); | 1407 | lo = kzalloc(sizeof(*lo), GFP_KERNEL); |
1403 | if (!lo) | 1408 | if (!lo) |
1404 | goto out; | 1409 | goto out; |
@@ -1443,17 +1448,13 @@ static void loop_del_one(struct loop_device *lo) | |||
1443 | kfree(lo); | 1448 | kfree(lo); |
1444 | } | 1449 | } |
1445 | 1450 | ||
1446 | static int loop_lock(dev_t dev, void *data) | ||
1447 | { | ||
1448 | mutex_lock(&loop_devices_mutex); | ||
1449 | return 0; | ||
1450 | } | ||
1451 | |||
1452 | static struct kobject *loop_probe(dev_t dev, int *part, void *data) | 1451 | static struct kobject *loop_probe(dev_t dev, int *part, void *data) |
1453 | { | 1452 | { |
1454 | struct loop_device *lo = loop_init_one(dev & MINORMASK); | 1453 | struct loop_device *lo; |
1455 | struct kobject *kobj; | 1454 | struct kobject *kobj; |
1456 | 1455 | ||
1456 | mutex_lock(&loop_devices_mutex); | ||
1457 | lo = loop_init_one(dev & MINORMASK); | ||
1457 | kobj = lo ? get_disk(lo->lo_disk) : ERR_PTR(-ENOMEM); | 1458 | kobj = lo ? get_disk(lo->lo_disk) : ERR_PTR(-ENOMEM); |
1458 | mutex_unlock(&loop_devices_mutex); | 1459 | mutex_unlock(&loop_devices_mutex); |
1459 | 1460 | ||
@@ -1466,7 +1467,7 @@ static int __init loop_init(void) | |||
1466 | if (register_blkdev(LOOP_MAJOR, "loop")) | 1467 | if (register_blkdev(LOOP_MAJOR, "loop")) |
1467 | return -EIO; | 1468 | return -EIO; |
1468 | blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS, | 1469 | blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS, |
1469 | THIS_MODULE, loop_probe, loop_lock, NULL); | 1470 | THIS_MODULE, loop_probe, NULL, NULL); |
1470 | 1471 | ||
1471 | if (max_loop) { | 1472 | if (max_loop) { |
1472 | printk(KERN_INFO "loop: the max_loop option is obsolete " | 1473 | printk(KERN_INFO "loop: the max_loop option is obsolete " |