]> 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)
commit57f3fc96bc70f9af81c37c65f593aedf27d61a73
tree5eb749bdeb0c889294504c4232ea0977d0f9966b
parent5cda1459f0a7c1c56aaf28ccc550a5b20fff9cfd
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: c34d04580f07 ("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