Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5248015imm; Tue, 18 Sep 2018 06:41:15 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYJdteE84c9ecvUVx2kPxMmv5rieuyD5e5FNiLLl+n0GZnM0ozJBWOTqbvV/6wILY2y5lRA X-Received: by 2002:a63:d002:: with SMTP id z2-v6mr28350077pgf.262.1537278075398; Tue, 18 Sep 2018 06:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537278075; cv=none; d=google.com; s=arc-20160816; b=oTmrrPR/40xHS0+3eK93i6nuYpLjfnuOb58LatCMujxV3ByPBdWz5kjK4bYGwgVibl 86QBFYfyiiotKStpILijNtkEIXsANhLRBLif5XfGVkb5sD4dfsqwZ6WkpHyitF8syie1 R5rthK2acDmEikg53TIF0sriPXEtgsHq7o6umLWbfFziSvIHQFQmPLnHTBCv+kjofwSE ljFzNVsR/NHCcmhawsQKDrDGr+kAkaoustHUOei72Xoql9ZqJlMjyKBBqmL318IiJLpH qwPS2kJMVKUUasBuBEUTWBEekyplp1UmcbOXDRCnG2j3TF+AQQocg5tnepvnGDBzZXf5 UXNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=1LuZsNUgBA+eyNeOcdlcGixuH62ULQFEHOZZ240MiIQ=; b=GIw8dWrrI1n8GwNq/NIkf9LLPReEBthVfwtRhz+wW/3RC5Wny6wl9EAY6WMTFfTJy5 b8AnFW5idwnx8ydoc0Y4WlsBvs/sTNdDeRK37EBuB+3H9vVcQX5oqbmm5o8J89lkP3fN 37oIxHQbl1Llx9LNsOWd9pCFNQE30ksUjXd8xV0SuUNQL0C3fb950o/MtJA6PM+Je7O4 aRmFlVcTEqOJ6dTnCkCuFklJHF7fpho1GJFFS6jKX/E2PJHVee5AD0eX5lc0pscqACzd k+RJbxVjEK7isNaxnourPALwR+K9iO3Qa/fXNEKlOOsdoUsIhdBhnoi6ni+PPrTrGJrD YRQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5-v6si19512778pls.431.2018.09.18.06.40.55; Tue, 18 Sep 2018 06:41:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729611AbeIRTNQ (ORCPT + 99 others); Tue, 18 Sep 2018 15:13:16 -0400 Received: from mail.bootlin.com ([62.4.15.54]:42956 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728413AbeIRTNQ (ORCPT ); Tue, 18 Sep 2018 15:13:16 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 6563520734; Tue, 18 Sep 2018 15:40:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.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 bbrezillon (AAubervilliers-681-1-99-10.w90-88.abo.wanadoo.fr [90.88.4.10]) by mail.bootlin.com (Postfix) with ESMTPSA id 1120E206DE; Tue, 18 Sep 2018 15:40:25 +0200 (CEST) Date: Tue, 18 Sep 2018 15:40:25 +0200 From: Boris Brezillon To: "Gustavo A. R. Silva" Cc: Tudor Ambarus , Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mtd: rawnand: atmel: Fix potential NULL pointer dereference Message-ID: <20180918154025.55137b03@bbrezillon> In-Reply-To: <20180918133317.GA17358@embeddedor.com> References: <20180918133317.GA17358@embeddedor.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gustavo, On Tue, 18 Sep 2018 08:33:17 -0500 "Gustavo A. R. Silva" wrote: > There is a potential execution path in which function > of_find_compatible_node() returns NULL. In such a case, > we end up having a NULL pointer dereference when accessing > pointer *nfc_np* in function of_clk_get(). > > So, we better don't take any chances and fix this by null > checking pointer *nfc_np* before calling of_clk_get(). > > Addresses-Coverity-ID: 1473052 ("Dereference null return value") Can you add a Fixes tag here? > Signed-off-by: Gustavo A. R. Silva > --- > drivers/mtd/nand/raw/atmel/nand-controller.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c > index a38633a..ffa0c6b6 100644 > --- a/drivers/mtd/nand/raw/atmel/nand-controller.c > +++ b/drivers/mtd/nand/raw/atmel/nand-controller.c > @@ -2035,6 +2035,11 @@ atmel_hsmc_nand_controller_legacy_init(struct atmel_hsmc_nand_controller *nc) > nfc_np = of_find_compatible_node(dev->of_node, NULL, > "atmel,sama5d3-nfc"); > Can you drop this blank line? > + if (!nfc_np) { > + dev_err(dev, "Could not find device node for sama5d3-nfc\n"); > + return -ENODEV; > + } > + > nc->clk = of_clk_get(nfc_np, 0); > if (IS_ERR(nc->clk)) { > ret = PTR_ERR(nc->clk); Thanks, Boris