From patchwork Wed May 9 10:13:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shmulik Ladkani X-Patchwork-Id: 157920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0FFFBB6F62 for ; Wed, 9 May 2012 21:30:39 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SS53M-00027C-4I; Wed, 09 May 2012 11:27:32 +0000 Received: from bombadil.infradead.org ([2001:4830:2446:ff00:4687:fcff:fea6:5117]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SS4gt-0000dD-GS for linux-mtd@merlin.infradead.org; Wed, 09 May 2012 11:04:19 +0000 Received: from mail-we0-f177.google.com ([74.125.82.177]) by bombadil.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SS3uU-00042Q-Jk for linux-mtd@lists.infradead.org; Wed, 09 May 2012 10:14:19 +0000 Received: by werp11 with SMTP id p11so71455wer.36 for ; Wed, 09 May 2012 03:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; bh=BWOuOBIwyCsFF4OjdAmLAS+qrIf+ukzYXK1WaKJcRfQ=; b=FTyvNIlAzYrmGBdba1KGFAkgx+aqoFBwwgScNXZzjeuwpI+WxdPQP7lKTdnqhgpqMc bimHi//JOvaMK4jgrf6Qj/zkjTOOuVKFqkaSaFH25FNM5hcZAnNY9jIS+JQi1bshfoKa a3V2XC3sUasrJsvuRXHB90GK0mWRaMRpcSZ+hjgEWmchHsnWZOJ8rsTmTQUvjbCQA7ta rrNwEYDwinPTjjcxaIJB6WHzcaknMtHn6WJ3XsJA6TZG3u+yVU5aP2FSnOTATw7xFaFG F9lL8tYGVDjaGP/jKfYt8seeYcqu+exuqvu2wkuvOJNRafJHvNM0gj/Up+lAFd3uFH+v jfgA== Received: by 10.180.80.104 with SMTP id q8mr53179325wix.14.1336558419160; Wed, 09 May 2012 03:13:39 -0700 (PDT) Received: from pixies.home.jungo.com (212-150-239-254.bb.netvision.net.il. [212.150.239.254]) by mx.google.com with ESMTPS id f19sm8144239wiw.11.2012.05.09.03.13.36 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 May 2012 03:13:37 -0700 (PDT) Date: Wed, 9 May 2012 13:13:34 +0300 From: Shmulik Ladkani To: linux-mtd@lists.infradead.org Subject: [PATCH 2/2] mtd: nand: check the return code of 'read_oob/read_oob_raw' Message-ID: <20120509131334.2d0b7160@pixies.home.jungo.com> In-Reply-To: <20120509130635.32973038@pixies.home.jungo.com> References: <20120509130635.32973038@pixies.home.jungo.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.9; i486-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20120509_061418_860298_DBBCF0A0 X-CRM114-Status: GOOD ( 14.33 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (shmulik.ladkani[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Brian Norris , David Woodhouse , Artem Bityutskiy X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Apparently, there is an implementor of 'read_oob' which may return an error inidication (e.g. docg4_read_oob may return -EIO). Test the return value of 'read_oob/read_oob_raw', and if negative, propagate the error, so it's returned by the '_read_oob' interface. Signed-off-by: Shmulik Ladkani --- drivers/mtd/nand/nand_base.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 4047d7c..d47586c 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1791,6 +1791,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, int readlen = ops->ooblen; int len; uint8_t *buf = ops->oobbuf; + int ret = 0; pr_debug("%s: from = 0x%08Lx, len = %i\n", __func__, (unsigned long long)from, readlen); @@ -1826,9 +1827,12 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, while (1) { if (ops->mode == MTD_OPS_RAW) - chip->ecc.read_oob_raw(mtd, chip, page); + ret = chip->ecc.read_oob_raw(mtd, chip, page); else - chip->ecc.read_oob(mtd, chip, page); + ret = chip->ecc.read_oob(mtd, chip, page); + + if (ret < 0) + break; len = min(len, readlen); buf = nand_transfer_oob(chip, buf, ops, len); @@ -1857,7 +1861,10 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, } } - ops->oobretlen = ops->ooblen; + ops->oobretlen = ops->ooblen - readlen; + + if (ret < 0) + return ret; if (mtd->ecc_stats.failed - stats.failed) return -EBADMSG;