Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5240511imm; Tue, 18 Sep 2018 06:34:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbAvZXdOAMZIrJNTCSYQ1iB9kn+uujXj708E8f49uVPnZR5gKtv3eph1lnRdAVzkcw6F8W+ X-Received: by 2002:a17:902:bb08:: with SMTP id l8-v6mr29470195pls.71.1537277681620; Tue, 18 Sep 2018 06:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537277681; cv=none; d=google.com; s=arc-20160816; b=TJoz8n1/YUdBSvilujwR2LdZAellYpGOvGWJmLf3lwvE74OV/J72EMmPikq+Y2XPV8 c/Nys7pW9e2l76bUH0N+947Tu2ZVn5dFi5iJem+YWuaxvCGqGRGsuKCFCK2UlSMnjHuV 0mo5R8338OJuy9BY/zNf+zBSMOJPHo/SEjz6kR7ZVwsI571fEumQYvgVAUb9OdbeCGlC ICKgpTlrxKZpMs27YsGAIFJuQxeqyVngBdUZRcvFrxJSx4vMdKildUI8/Mp304L+td9J tGzu2vS1U/jHUCyNE/jdoseRxPv11HBfKqoQaYnehGWOoC56/zLHEwNo6N7+nKe2kjQS pSlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date; bh=D1NlnUqpBe7XYLDmLSaXj4KPtVH5BW74MPFJ/1CSIH4=; b=n0zwp2GKBgaUIIZ7eHiAoZ/X3RGZp+4uYI63mvPGFWm3064nrIzI31WVubrZlwqmiK rU1o4VFPvQqyEjXM+Y8JQMlIQw+vbVSOgSoNiCmKHCjaAPR7NEPt/fwp4d0n8mOZoimK pseCmuUh5nttoZBrFCy9HmkXHXzLSayr/t7K28euqQiajr6JJgmSB7ap9pNCy2Bj0VuO p1VpOKOEKzCc3iGqqYKTG0Plp3UOBYMeL/8CyiQcGBPiBD0WpKU1iuwauTuus3lvifiz eqMOW/348K+2hUGwYZQvdjP0+nL26W0t4Lmqi85bgfasit/U8EkYOVKNeoLgym6jhykf cjfQ== 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 a98-v6si19218584pla.396.2018.09.18.06.34.24; Tue, 18 Sep 2018 06:34:41 -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 S1729674AbeIRTGV (ORCPT + 99 others); Tue, 18 Sep 2018 15:06:21 -0400 Received: from gateway21.websitewelcome.com ([192.185.45.155]:15166 "EHLO gateway21.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728575AbeIRTGU (ORCPT ); Tue, 18 Sep 2018 15:06:20 -0400 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 29A9C401200B7 for ; Tue, 18 Sep 2018 08:33:43 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id 2G81gmvx1aSey2G8DgDC5c; Tue, 18 Sep 2018 08:33:42 -0500 X-Authority-Reason: nr=8 Received: from [189.250.49.176] (port=38858 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.91) (envelope-from ) id 1g2G7z-00147a-59; Tue, 18 Sep 2018 08:33:19 -0500 Date: Tue, 18 Sep 2018 08:33:17 -0500 From: "Gustavo A. R. Silva" To: Tudor Ambarus , Boris Brezillon , Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] mtd: rawnand: atmel: Fix potential NULL pointer dereference Message-ID: <20180918133317.GA17358@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.250.49.176 X-Source-L: No X-Exim-ID: 1g2G7z-00147a-59 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.250.49.176]:38858 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 13 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") 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"); + 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); -- 2.7.4