提交 e5d66a10 编写于 作者: C Christoph Hellwig 提交者: Jens Axboe

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: NChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210623145908.92973-8-hch@lst.deSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 18d1f200
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册