Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp419018imm; Wed, 19 Sep 2018 00:45:22 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZexO3WA71spa/M/Ak4E2/7cdJbtQjecuuja6CYTmClF5BXyuwZOnXs9Wt0/dqfQ0FY/3n1 X-Received: by 2002:a17:902:1681:: with SMTP id h1-v6mr32834124plh.262.1537343122083; Wed, 19 Sep 2018 00:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537343122; cv=none; d=google.com; s=arc-20160816; b=BuH4/BGYKMDoZGkdrnFagVdBPMkl1DCim8SsRKEDKULZhRJedGvZhe/RG+zzobBhGS DRazH2gTJ/zfLYfqkUAUsOlDFU83umLvAsnt8HGUg33JrsyUHrxF935YsR1DqM98583p +PB5gsGmQeu7MP69mXeVN+xXNm6aJOcvZBVvP3pwt9II6HbvKDA6uSkYc5H6tmePrHJ2 eaEdM2QiWiC5efQCF7ZI94U6+i6whbZT++4B/VLDX+lCIGkYCJiOBfeORRiWH31pBNkb F7vD1f3ZJb/+/GfHD+H0q3ZutQio+ohyRT/1OQ/JxtMbtM19fUKBL0CkbaXtggoHGDj7 vaew== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=2k3LEwwwHLX1Cuv9NtaY3cL5hoUXZpxJihgriYMJNds=; b=k62M4MKCLV9QAWIKp14KEa5rOIimisnq17du1x3zACIS4JRnG+NIu549k8Mntpz+Mi 2zrp8EcaySSh+h2I4/dfUq+m2put8XclIc2bnwlo0JbRe5ws+7BjacrLHsQQJAmptLe7 ARLaOGRYvRZOqZusrc00R0vrW2O1ird2FTMjBZwl3iBKg0V0loziL18GGGovUfvgoSV0 zSJZ3zyGn7kJI7GG9ggRJZ4w5g2J0c1mnuW+0VI5kGtFpL82hkpJgdSyLk83Ls4B4cyD NS2wqsCKLW8JLhG9yzU+F70mWxz+odGPsiReA/w0fRIOEav4vWgoKFFdPXB2EUL8WM8w IddQ== 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 j9-v6si20228476plk.153.2018.09.19.00.45.03; Wed, 19 Sep 2018 00:45:22 -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 S1730688AbeISNVj (ORCPT + 99 others); Wed, 19 Sep 2018 09:21:39 -0400 Received: from esa2.microchip.iphmx.com ([68.232.149.84]:6468 "EHLO esa2.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727056AbeISNVj (ORCPT ); Wed, 19 Sep 2018 09:21:39 -0400 X-IronPort-AV: E=Sophos;i="5.53,393,1531810800"; d="scan'208";a="20143902" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 19 Sep 2018 00:44:58 -0700 Received: from localhost.localdomain (10.10.76.4) by chn-sv-exch05.mchp-main.com (10.10.76.106) with Microsoft SMTP Server id 14.3.352.0; Wed, 19 Sep 2018 00:44:57 -0700 Subject: Re: [PATCH v2] mtd: rawnand: atmel: Fix potential NULL pointer dereference To: "Gustavo A. R. Silva" , Boris Brezillon , Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches CC: , , References: <20180918135555.GA18114@embeddedor.com> From: Tudor Ambarus Message-ID: <61472393-b699-45b4-6d74-cfa774669ad2@microchip.com> Date: Wed, 19 Sep 2018 10:44:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20180918135555.GA18114@embeddedor.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/18/2018 04:55 PM, 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") > Fixes: f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver") > Signed-off-by: Gustavo A. R. Silva Acked-by: Tudor Ambarus > --- > Changes in v2: > - Add Fixes tag to the commit log. > - Remove blank line before null checking nfc_np. > > drivers/mtd/nand/raw/atmel/nand-controller.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c > index a38633a..5bfbe97 100644 > --- a/drivers/mtd/nand/raw/atmel/nand-controller.c > +++ b/drivers/mtd/nand/raw/atmel/nand-controller.c > @@ -2034,6 +2034,10 @@ atmel_hsmc_nand_controller_legacy_init(struct atmel_hsmc_nand_controller *nc) > nand_np = dev->of_node; > 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)) { >