From patchwork Mon Feb 12 21:03:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 872404 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1236::1; helo=casper.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="h1gjCjzv"; dkim=pass (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="cA4vuTGI"; dkim-atps=neutral Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zgJ812Kl7z9s7h for ; Tue, 13 Feb 2018 08:04:33 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Tqe1djnCGfB4u9GyTr0mK0BNhkyna2yf8oTFc2TP5tI=; b=h1gjCjzvNhKZOG0OaNqM28z8vV opMZlzL/j50gFPJnx9k/STo1127hYwJvDMbkGMlILo9X7toiTiCvtcUSwhjSydknsEannWxj0A0JI c28MNVzsdlmKVCnWr6FnlQi4dm331kxvRRjsABMfiBdjRFCGitKedhvgVq4NgFT4eXDoqStaqlYUT lZrPw2oZbZ7I/WhL6nbHts96o1S6c0mfzYvD+3QfRoCJCr0OHUjmg+xthDuvx+mS7d5vTJhqm97jQ /bwXNVJ3gl7rsVn+SksefMLPOmGMcxYfR/SG5ro5nUOysB0o08VhUuY1T02ELlSS/eSGSqJ7Lz7fV 1+Ej9JOA==; Received: from [198.137.202.133] (helo=bombadil.infradead.org) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1elLGf-0007bF-Dd; Mon, 12 Feb 2018 21:04:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Tqe1djnCGfB4u9GyTr0mK0BNhkyna2yf8oTFc2TP5tI=; b=cA4vuTGIApzto43Fq2srdBX+TP fNCN7LL6S8ECuKzxCGoKqgJZ7DMEbWgDjNIuzxERWFQ56mNS/opePCqxcMj2QAhz0YimMBqu9Vozh fqk1t35hgwY01fnYJZQi+GVuXpDA/TZKK8i2vrWhsaHWkuZkiknbhJYY2SB1kZrGh+uQsrWzPegcH UkNIy7SH65gnqR+w+M0FBKzAXpw4nwEiVP+bQEwoi8vV/DQ4H2DNjUtzeh23aOzlAB+9EoGeN0fft FbitUE1qMv6OMJZDJ4QCXiVj1kjhOg1Fz1qHms0jzjAHEGMw7RuOmiWvyhgFTHJeKhC2XZzV6pAmW 46EYv38A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1elLGZ-0006yi-T2; Mon, 12 Feb 2018 21:03:59 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1elLGO-0006tF-G2 for linux-mtd@lists.infradead.org; Mon, 12 Feb 2018 21:03:50 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 32C022036E; Mon, 12 Feb 2018 22:03:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (91-160-177-164.subs.proxad.net [91.160.177.164]) by mail.free-electrons.com (Postfix) with ESMTPSA id B5D4620703; Mon, 12 Feb 2018 22:03:25 +0100 (CET) From: Boris Brezillon To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Cyrille Pitchen , linux-mtd@lists.infradead.org Subject: [PATCH 1/5] mtd: Initialize ->fail_addr early in mtd_erase() Date: Mon, 12 Feb 2018 22:03:07 +0100 Message-Id: <20180212210311.23244-2-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180212210311.23244-1-boris.brezillon@bootlin.com> References: <20180212210311.23244-1-boris.brezillon@bootlin.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Bert Kenward , Solarflare linux maintainers , Artem Bityutskiy , Miquel Raynal , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Joern Engel , Greg Kroah-Hartman , Kyungmin Park , netdev@vger.kernel.org, Paul Mackerras , Benjamin Herrenschmidt , Edward Cree , Robert Jarzmik MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org mtd_erase() can return an error before ->fail_addr is initialized to MTD_FAIL_ADDR_UNKNOWN. Move this initialization at the very beginning of the function. Signed-off-by: Boris Brezillon Reviewed-by: Richard Weinberger --- drivers/mtd/mtdcore.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index a1c94526fb88..c87859ff338b 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -953,6 +953,8 @@ EXPORT_SYMBOL_GPL(__put_mtd_device); */ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) { + instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN; + if (!mtd->erasesize || !mtd->_erase) return -ENOTSUPP; @@ -961,7 +963,6 @@ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) if (!(mtd->flags & MTD_WRITEABLE)) return -EROFS; - instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN; if (!instr->len) { instr->state = MTD_ERASE_DONE; mtd_erase_callback(instr);