Message ID | 1534839799-14112-1-git-send-email-yamada.masahiro@socionext.com |
---|---|
State | New |
Headers | show
Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4977097ljj; Tue, 21 Aug 2018 01:24:06 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx4y4dbWnaiTeQTkkGPsq7USspFV5f97Pn1zR4AzqqOipKS768xDoQCVJPDZ6aTYo8ruYHa X-Received: by 2002:a63:4826:: with SMTP id v38-v6mr10925792pga.379.1534839846195; Tue, 21 Aug 2018 01:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534839846; cv=none; d=google.com; s=arc-20160816; b=K0Ny1dDYnrsUpyeZz28ogQvdvrgDbPk4uYcTKgX4scbB0pmoEUYKfmEH4ajzqD15LQ iSataYj1noahCg9VjZF5C4kFZIvu8EMzkHzJHmOjaY5nFTo2bNEt3gRbeJsbPM0pGT3R 8OXzeyvVFUEDXdK/MbBu+uyqMZIMDr0KhUL30enYN4VP7pO+DLGgWQVm0luIqECyZpiV aqiH6Li+mvLX0hsToR4nhfRH6oTz3/a1kF4zF3Oje6b+1wvVet3JRCBR9CYAX4XtvKZa 8r6f9xPd1W/L1wz+XG54U8Xahqv/bnD4skAkBxAkUiPQuNwrm9VrCuRHz+9LW3WdDVSM wp/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:dkim-signature :dkim-filter:dkim-signature:arc-authentication-results; bh=yZLkz+1zBGqQwXH8dMov+hMJ29+IepevbxFCMPrxEqQ=; b=LHyL8DfBVvrhxNs/YuOCS+Ni7QVz0JjYhsW3jy9taVG6iZ0uExzj275wCBidklXVLQ F8LvB5thAmFoAqCO6OoDsfakQcYFZ/mNfC461lssbXJsytObXoZtN5vVNt1B7wAeyKD9 1l1BUOCZInO2JCDRCrP43Ap91Ikr7a4qoOWYH34pNsMF047WEsPIV5bA9zuqTF7LYdnD 1SXEJm92CfIRBkNowxwecTeaZ/fQ8yztkSSfbkd8qzQ76xBIj7phC/znYbL3+15tsZDb hwmOIz1PsREQzH+uog0MNiKNhYKdyIA5Me0Tp3isxMvoIKThgyZSaaLPYWcEi10gO4SH 82wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=nc7iOSwE; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=lPWCW4yo; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: <linux-mtd-bounces+patch=linaro.org@lists.infradead.org> Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id k11-v6si11624192pgj.688.2018.08.21.01.24.05 for <patch@linaro.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Aug 2018 01:24:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=nc7iOSwE; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=lPWCW4yo; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.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: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:In-Reply-To: References:List-Owner; bh=yZLkz+1zBGqQwXH8dMov+hMJ29+IepevbxFCMPrxEqQ=; b=nc7 iOSwE5hy+mGlScm9k9RPR2loI+V1cmWe6ThYdTVcuDsLMedBwYF66QjZww9JOLkRl+YEa4TxmQykT JohKSg0jEKeVsCbRLSxrc0nzpuxPQl/JafeCFkF1TJksOaKYfGIVw7lT8Q9eRq1+O9dqZZZWJe/hN TeXGaWI5I8rrY2E42aHrkO/Xst+4nO+a0Pa3T/rnNFx5i06DkLZrTfHVv0K28+viFB03ATlfGcr27 PIyGaFLwrsJ/NTucPtn3Y1W/H5fLZ7nIjwnxL6C8UcW6IWhqXhbsXtSDPUOCRte18Qh5s7kgfmJb8 1fx02E7uOYplGYzgeWuhA+uY/HTnupw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fs1xE-0005K6-LS; Tue, 21 Aug 2018 08:23:56 +0000 Received: from conuserg-07.nifty.com ([210.131.2.74]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fs1xB-0005JY-68 for linux-mtd@lists.infradead.org; Tue, 21 Aug 2018 08:23:55 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id w7L8NMfY009148; Tue, 21 Aug 2018 17:23:22 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w7L8NMfY009148 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1534839803; bh=cHlV1fzTPy2AxA0OS8cxvziMcEGIywYFVaQHfV5ATVQ=; h=From:To:Cc:Subject:Date:From; b=lPWCW4yoiI7ZOojB5oQd7HPFPlYg0W1pcYGa+NrXQ03MoNNXT6+HorumyrSQHHsca jGe01k4xzrcj8CiNv6obsSgSMvQDNHVJJW5mphvVoI3Tv1YK3FgGKtR7fFvgNSj6x7 VVcm8YNSJWXISZqzXatoOa7evvWWGGl5g/+HCR96QwvKAT96YBzfEdhl6XFvkzH8GX TNjhhnLul9OzlQF6GLnXWdL+aHS3sVIOijW2kv6p6iiE/CVAoZXxdIGiJ0Hz02YRvZ FGzPzZI61PHC1avf3Np7dxGZfHkT58+U8FcjNMNIVU/tcAO2v174ctXZXQcGxpzKZN vDr2IxQnsNTjg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada <yamada.masahiro@socionext.com> To: linux-mtd@lists.infradead.org, Boris Brezillon <boris.brezillon@bootlin.com>, Miquel Raynal <miquel.raynal@bootlin.com> Subject: [PATCH] mtd: rawnand: denali: do not pass zero maxchips to nand_scan() Date: Tue, 21 Aug 2018 17:23:19 +0900 Message-Id: <1534839799-14112-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180821_012353_579281_CF385CCE X-CRM114-Status: GOOD ( 13.36 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [210.131.2.74 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 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 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list <linux-mtd.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mtd>, <mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-mtd/> List-Post: <mailto:linux-mtd@lists.infradead.org> List-Help: <mailto:linux-mtd-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mtd>, <mailto:linux-mtd-request@lists.infradead.org?subject=subscribe> Cc: Marek Vasut <marek.vasut@gmail.com>, Richard Weinberger <richard@nod.at>, linux-kernel@vger.kernel.org, Masahiro Yamada <yamada.masahiro@socionext.com>, Brian Norris <computersforpeace@gmail.com>, David Woodhouse <dwmw2@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" <linux-mtd-bounces@lists.infradead.org> Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org |
Series |
mtd: rawnand: denali: do not pass zero maxchips to nand_scan()
|
expand
|
diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index ca18612..3e4b8e1 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -1086,7 +1086,6 @@ static void denali_reset_banks(struct denali_nand_info *denali) } dev_dbg(denali->dev, "%d chips connected\n", i); - denali->max_banks = i; } static void denali_hw_init(struct denali_nand_info *denali)
Commit 49aa76b16676 ("mtd: rawnand: do not execute nand_scan_ident() if maxchips is zero") gave a new meaning for calling nand_scan_ident() with maxchips=0. It is a special usage for some drivers such as docg4, but in fact the Denali driver may pass maxchips=0 to nand_scan() when the driver is enabled but no NAND chip is found on the board for some reasons. If nand_scan_with_ids() is called with maxchips=0, nand_scan_ident() is skipped, i.e. nand_set_defaults() is skipped. Therefore, the driver must have set chip->controller beforehand. Otherwise, nand_attach() causes NULL pointer dereference. In fact, the Denali controller knows the number of connected chips before calling nand_scan_ident(); if DEVICE_RESET fails, there is no chip in that chip select. Then, denali_reset_banks() sets the maxchips to the number of detected chips. If no chip is found, it is zero. The reason of this trick was, as commit f486287d2372 ("mtd: nand: denali: fix bank reset function to detect the number of chips") explained, nand_scan_ident() issued Set Features (0xEF) command to all CS lines, some of which may not be connected with a chip. Then, the driver would wait until R/B# response, which never happens. This problem was solved by commit 107b7d6a7ad4 ("mtd: rawnand: avoid setting again the timings to mode 0 after a reset"). In the current code, nand_setup_data_interface() is called from nand_scan_tail(), which is after the chip detection is done. Remove the code that is causing NULL pointer dereference. Now, the maxchips passed to nand_scan() is the maximum number of chip selects supported by the IP (typically 4 or 8). Leave all the chip detection process to nand_scan_ident(). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> --- drivers/mtd/nand/raw/denali.c | 1 - 1 file changed, 1 deletion(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/