提交 b777f4c4 编写于 作者: D Dan Carpenter 提交者: Jens Axboe

ataflop: fix off by one in ataflop_probe()

Smatch complains that the "type > NUM_DISK_MINORS" should be >=
instead of >.  We also need to subtract one from "type" at the start.

Fixes: bf9c0538 ("ataflop: use a separate gendisk for each media format")
Reported-by: Nkernel test robot <lkp@intel.com>
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 1ffec389
......@@ -2001,7 +2001,10 @@ static void ataflop_probe(dev_t dev)
int drive = MINOR(dev) & 3;
int type = MINOR(dev) >> 2;
if (drive >= FD_MAX_UNITS || type > NUM_DISK_MINORS)
if (type)
type--;
if (drive >= FD_MAX_UNITS || type >= NUM_DISK_MINORS)
return;
mutex_lock(&ataflop_probe_lock);
if (!unit[drive].disk[type]) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册