Skip to content

Commit

Permalink
ataflop: fix off by one in ataflop_probe()
Browse files Browse the repository at this point in the history
Smatch complains that the "type > NUM_DISK_MINORS" should be >=
instead of >.  We also need to subtract one from "type" at the start.

Fixes: bf9c053 ("ataflop: use a separate gendisk for each media format")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Dan Carpenter authored and axboe committed Apr 21, 2021
1 parent 1ffec38 commit b777f4c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/block/ataflop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down

0 comments on commit b777f4c

Please sign in to comment.