From patchwork Tue Sep 28 05:22:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 1533709 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=X2HzaJiu; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=mld55F53; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HJSbC1KQlz9t1C for ; Tue, 28 Sep 2021 15:23:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BQSsQgBNzwR74NcQMT0zvqNYURiP4cXlrZ9FnrfUR2U=; b=X2HzaJiupzQRy0 lMrKkpdK1gMaqdKKBXz/ZsEP+to/G74WOO0NhWFknbC00vuTvw2mDv0ZD2DBe9yIUQ0y6fHmPFQCT yjcZXkQNeQ3nMWiznfGeMzkCfckz3CCU6wF9oa31IOKMfOmJpuhwb0+iTBfbUaP1Qq8Bbb07yp2JY sJAEuK81JCAn1VE/96WHcy+lYr8wS+R3Ekpr7PCLXY2wn6K+nW+k0xIz9Xkln7dqNwqdDYwWV3NbE mV4UwP4VvsZ0goMLDB6UiYXrqOec8QvrZIVMxyuTr+PJ9pvNWe99EqBaDpcXwTG4p+O3WH/5yuNNr evlPsPmEXIyvjC1CCPeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mV5a3-005cIN-34; Tue, 28 Sep 2021 05:23:03 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mV5a1-005cIF-Vn for linux-mtd@bombadil.infradead.org; Tue, 28 Sep 2021 05:23:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=lmHEDTWGofeDOwHsn0RpYTE0PMMmj0L5m+XiC3VnX2w=; b=mld55F53YIGAnwfDfJb1dpucQE DQeivNpnLZgobDKZWtBQGX2JzkHqC2GFdR/7SofbBXFoRfBIGVlqBxjh1dOIOjLEfx25zcMmvLige +ygr040OwDq3n7tJ+uWWssNbsEJhWjehCfcP7JqE5++m5jXgNAtsGyIwXxqwTbdyxb8DqmpCHUs1h AVzb/F5l7OwQNzHh8e3dp7T0uuNQ6bPPODq9jNBCwZm8fv7fAFouxF80P8o0Zd2jiJgRnD8ZpsVJw vsleMY54A0LlhHhoo1rVUbLziYmmA9Q502Xl23vY+f9zi/i9/VByppiDdENanm0yDaqAEI4ScpWaS WxzNk15g==; Received: from p4fdb05cb.dip0.t-ipconnect.de ([79.219.5.203] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mV5Zg-00AW6x-4a; Tue, 28 Sep 2021 05:22:48 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Martin K. Petersen" , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-block@vger.kernel.org, linux-mtd@lists.infradead.org, linux-scsi@vger.kernel.org Subject: [PATCH 1/5] mtd_blkdevs: remove the sector out of range check in do_blktrans_request Date: Tue, 28 Sep 2021 07:22:07 +0200 Message-Id: <20210928052211.112801-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210928052211.112801-1-hch@lst.de> References: <20210928052211.112801-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The block layer already performs this check, no need to duplicate it in the driver. Signed-off-by: Christoph Hellwig Reviewed-by: Miquel Raynal --- drivers/mtd/mtd_blkdevs.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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;