]> git.baikalelectronics.ru Git - kernel.git/commit
ataflop: potential out of bounds in do_format()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 21 Apr 2021 10:18:35 +0000 (13:18 +0300)
committerJens Axboe <axboe@kernel.dk>
Wed, 21 Apr 2021 15:15:25 +0000 (09:15 -0600)
commita98dc5734b18748ad4140939e9d1694b3c9428b3
tree5eb749bdeb0c889294504c4232ea0977d0f9966b
parenta9fa390d51ce5d5876f851ae6cab2265bb1fdae1
ataflop: potential out of bounds in do_format()

The function uses "type" as an array index:

q = unit[drive].disk[type]->queue;

Unfortunately the bounds check on "type" isn't done until later in the
function.  Fix this by moving the bounds check to the start.

Fixes: 7c164acc8220 ("ataflop: use a separate gendisk for each media format")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ataflop.c