Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3438360imu; Sun, 11 Nov 2018 15:06:14 -0800 (PST) X-Google-Smtp-Source: AJdET5dGLymsPgtLygqKZ+42jD4GQdihOxQ5jAUlsnlCkEwT7hlwNkBtwHpndDKD8bDi7ba6VQu+ X-Received: by 2002:a63:6b08:: with SMTP id g8mr15227089pgc.119.1541977573990; Sun, 11 Nov 2018 15:06:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977573; cv=none; d=google.com; s=arc-20160816; b=tg+Ln+hYWtgyeC0MoRz3Idv7eIjF8o9U5Tyv6+N95J35WTcifpYAZTikybcu4BxRX5 dr/v3i09KXcBOJ9xLdTdTg0Tf9l1C4LhnDGL4cd5MfZtoCXoC9ebf8MD21y2wKY+rT44 L9VzML8LVhSuUR6pp8s4GhlR3IhgJA7T6ULRR2IczU72ZizJYPkG56Fly5Ij0ZNBh4jz IojoEPlzC0ZsA6BzOACLuTYJ83PjNDSTI6MAi735S5UOOAo1nwQb6WsqfWkJmDLhANPi 8QYuhMDggJNYm7uzaYk/cxBbIy+GcUPmMU9qHEeWfe1XXsPBX6r3RSmUXl1XzqoTgT2f xTxQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7JhfEkwp0BHpup9eJxE45G5ilkrMJX4lZjz9e9hFbdM=; b=q7j1XPly6HMTf3SireMq+qRvfdXCRO+ORV0ko8BDjYbSSBsm386m1N/n6Pjv8gxxkT mp3LpC9sudrTbqbdbPYB8WZBagSqBBUUhb9PDJ9wUU2rmeuSKh338++Z92QF4WbFpppO byH6Bv94TwsiYVNSCglRTn4uQ6mEhd/mTAkzObf8ym1twvXBmt9AwzbEOQdXyNRlCXd+ r+SwZNmGBPAmTTDRJRJ/QNkV8P+g5IWxB271ACzpRjsh7Y2FnEkWBEog8WbCKdo9T/T8 5COgTGd+44DDyH7R+sA+d2P1jIZxxfg+CH2SZcNCZGryrM/D8QXBYjDmPdTh/leoO/ey BUvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sYhZLdCx; 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 m38si14855363pgl.125.2018.11.11.15.05.59; Sun, 11 Nov 2018 15:06:13 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=sYhZLdCx; 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 S2390448AbeKLIWQ (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:51332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390429AbeKLIWP (ORCPT ); Mon, 12 Nov 2018 03:22:15 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6C24421582; Sun, 11 Nov 2018 22:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975538; bh=GsI1RyvFBZ293OtLC+o0zmdBILzdIU/cn7cwWYXpcOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sYhZLdCxU+jwm6RXbmAx2WdgnwYMPUHMuinqOGnT/dqiZxZKjrMti7vh09ZdRKCDe Hm0D5JFJcmWzv+Itlqd1LYVOxfbRXLrEt3m3Ws1lwiczO3YLAp2IZIwS1AxoHB79wj gg8KHcyPh3+x4ob+lhEanePp/NvfQWEO1ArtJ9XA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Boris Brezillon , Tudor Ambarus , Miquel Raynal , Sasha Levin Subject: [PATCH 4.14 058/222] mtd: rawnand: atmel: Fix potential NULL pointer dereference Date: Sun, 11 Nov 2018 14:22:35 -0800 Message-Id: <20181111221653.215859025@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Gustavo A. R. Silva" [ Upstream commit fbed20280d912449cfb40c382cb55e3d11502587 ] 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 Reviewed-by: Boris Brezillon Acked-by: Tudor Ambarus Signed-off-by: Miquel Raynal Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/atmel/nand-controller.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/mtd/nand/atmel/nand-controller.c +++ b/drivers/mtd/nand/atmel/nand-controller.c @@ -2079,6 +2079,10 @@ atmel_hsmc_nand_controller_legacy_init(s 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)) {