summaryrefslogtreecommitdiff
path: root/drivers/block/loop.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-06-23 16:59:06 +0200
committerJens Axboe <axboe@kernel.dk>2021-06-30 15:34:13 -0600
commite5d66a10324f2a0c31153fd6210d99a9d00ef047 (patch)
treebe57a00068fe215620f6a026f57412e27ed97e3f /drivers/block/loop.c
parent18d1f200b3807c383d80cc00d6bbdee288e63b1f (diff)
loop: don't allow deleting an unspecified loop device
Passing a negative index to loop_lookup while return any unbound device. Doing that for a delete does not make much sense, so add check to explicitly reject that case. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20210623145908.92973-8-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/loop.c')
-rw-r--r--drivers/block/loop.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index c18e2930ca11..b217065a6d67 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2404,6 +2404,11 @@ static int loop_control_remove(int idx)
{
struct loop_device *lo;
int ret;
+
+ if (idx < 0) {
+ pr_warn("deleting an unspecified loop device is not supported.\n");
+ return -EINVAL;
+ }
ret = mutex_lock_killable(&loop_ctl_mutex);
if (ret)