diff mbox series

[1/5] mtd_blkdevs: remove the sector out of range check in do_blktrans_request

Message ID 20210928052211.112801-2-hch@lst.de
State Not Applicable
Headers show
Series [1/5] mtd_blkdevs: remove the sector out of range check in do_blktrans_request | expand

Commit Message

Christoph Hellwig Sept. 28, 2021, 5:22 a.m. UTC
The block layer already performs this check, no need to duplicate it in
the driver.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/mtd/mtd_blkdevs.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Comments

Miquel Raynal Sept. 28, 2021, 8:51 a.m. UTC | #1
Hi Christoph,

hch@lst.de wrote on Tue, 28 Sep 2021 07:22:07 +0200:

> 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>

Thanks,
Miquèl
diff mbox series

Patch

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index b8ae1ec14e178..5ce5da705ac00 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -52,17 +52,11 @@  static blk_status_t do_blktrans_request(struct mtd_blktrans_ops *tr,
 	block = blk_rq_pos(req) << 9 >> tr->blkshift;
 	nsect = blk_rq_cur_bytes(req) >> tr->blkshift;
 
-	if (req_op(req) == REQ_OP_FLUSH) {
+	switch (req_op(req)) {
+	case REQ_OP_FLUSH:
 		if (tr->flush(dev))
 			return BLK_STS_IOERR;
 		return BLK_STS_OK;
-	}
-
-	if (blk_rq_pos(req) + blk_rq_cur_sectors(req) >
-	    get_capacity(req->rq_disk))
-		return BLK_STS_IOERR;
-
-	switch (req_op(req)) {
 	case REQ_OP_DISCARD:
 		if (tr->discard(dev, block, nsect))
 			return BLK_STS_IOERR;