]> git.baikalelectronics.ru Git - kernel.git/commitdiff
loop: don't call loop_lookup before adding a loop device
authorChristoph Hellwig <hch@lst.de>
Wed, 23 Jun 2021 14:59:03 +0000 (16:59 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 30 Jun 2021 21:34:13 +0000 (15:34 -0600)
loop_add returns the right error if the slot wasn't available.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210623145908.92973-5-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/loop.c

index d587ad210ecd984e9750593904af5414b3a81610..5b77c1e160b5edbcd9174061e4caea055ade9e59 100644 (file)
@@ -2388,14 +2388,12 @@ out:
 static void loop_probe(dev_t dev)
 {
        int idx = MINOR(dev) >> part_shift;
-       struct loop_device *lo;
 
        if (max_loop && idx >= max_loop)
                return;
 
        mutex_lock(&loop_ctl_mutex);
-       if (loop_lookup(&lo, idx) < 0)
-               loop_add(idx);
+       loop_add(idx);
        mutex_unlock(&loop_ctl_mutex);
 }
 
@@ -2412,11 +2410,6 @@ static long loop_control_ioctl(struct file *file, unsigned int cmd,
        ret = -ENOSYS;
        switch (cmd) {
        case LOOP_CTL_ADD:
-               ret = loop_lookup(&lo, parm);
-               if (ret >= 0) {
-                       ret = -EEXIST;
-                       break;
-               }
                ret = loop_add(parm);
                break;
        case LOOP_CTL_REMOVE: