Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd_blkdevs: remove the sector out of range check in do_blktrans_request

The block layer already performs this check, no need to duplicate it in
the driver.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20211126121802.2090656-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
82baa324 af22fef3

+2 -8
+2 -8
drivers/mtd/mtd_blkdevs.c
··· 54 54 block = blk_rq_pos(req) << 9 >> tr->blkshift; 55 55 nsect = blk_rq_cur_bytes(req) >> tr->blkshift; 56 56 57 - if (req_op(req) == REQ_OP_FLUSH) { 57 + switch (req_op(req)) { 58 + case REQ_OP_FLUSH: 58 59 if (tr->flush(dev)) 59 60 return BLK_STS_IOERR; 60 61 return BLK_STS_OK; 61 - } 62 - 63 - if (blk_rq_pos(req) + blk_rq_cur_sectors(req) > 64 - get_capacity(req->rq_disk)) 65 - return BLK_STS_IOERR; 66 - 67 - switch (req_op(req)) { 68 62 case REQ_OP_DISCARD: 69 63 if (tr->discard(dev, block, nsect)) 70 64 return BLK_STS_IOERR;