Skip to contentSkip to conversation

loop: Make user notify for adding loop device failed

PATCH In review Minfei Huang 4 participants 4 messages Jun 7, 2016 – Jul 12, 2016 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 loop: Make user notify for adding loop device failed

There is no error number returned if loop driver fails in function alloc_disk to add new loop device. Add a correct error number to make user notify in this case.

---
 drivers/block/loop.c | 1 +
 1 file changed, 1 insertion(+)
drivers/block/loop.c +1 -0
index 1fa8cc2..2caaf6f 100644
@@ -1765,6 +1765,7 @@ static int loop_add(struct loop_device **l, int i)
 	 */
 	queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, lo->lo_queue);
 
+	err = -ENOMEM;
 	disk = lo->lo_disk = alloc_disk(1 << part_shift);
 	if (!disk)
 		goto out_free_queue;
Signature · 1 line
2.7.4 (Apple Git-66)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Minfei Huang

There is no error number returned if loop driver fails in function alloc_disk to add new loop device. Add a correct error number to make user notify in this case.

Good catch!

Quoted 19 lines
---
 drivers/block/loop.c | 1 +
 1 file changed, 1 insertion(+)
drivers/block/loop.c +1 -1
index 1fa8cc2..2caaf6f 100644
@@ -1765,6 +1765,7 @@ static int loop_add(struct loop_device **l, int i)
         */
        queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, lo->lo_queue);
 
+       err = -ENOMEM;
        disk = lo->lo_disk = alloc_disk(1 << part_shift);
        if (!disk)
                goto out_free_queue;
--

2.7.4 (Apple Git-66)

Reviewed-by on v1 1/1
#2 lore raw
In reply to Minfei Huang
Quoted 14 lines · Minfei Huang

There is no error number returned if loop driver fails in function alloc_disk to add new loop device. Add a correct error number to make user notify in this case.

---
 drivers/block/loop.c | 1 +
 1 file changed, 1 insertion(+)
drivers/block/loop.c +0 -0
index 1fa8cc2..2caaf6f 100644

drivers/block/loop.c static int loop_add(struct loop_device **l, int i) · line 1771

Quoted 7 lines
drivers/block/loop.c +1 -0
@@ -1765,6 +1765,7 @@ static int loop_add(struct loop_device **l, int i)
 	 */
 	queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, lo->lo_queue);
 
+	err = -ENOMEM;
 	disk = lo->lo_disk = alloc_disk(1 << part_shift);
 	if (!disk)
 		goto out_free_queue;

Looks good.

#3 lore raw
In reply to Minfei Huang
Quoted 3 lines · Minfei Huang

There is no error number returned if loop driver fails in function alloc_disk to add new loop device. Add a correct error number to make user notify in this case.

Sorry about the delay, vacation got in the way. Added for 4.8, thanks.

Signature · 1 line
Jens Axboe