Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3488256imu; Sun, 11 Nov 2018 16:13:53 -0800 (PST) X-Google-Smtp-Source: AJdET5eDhnXE3xTSxYrC1y+xP+0PnxqBU0WCaNuHYDERrvfnG8ZW0ObkGQ46nSy9lZ2aiMejjs4U X-Received: by 2002:a63:ec13:: with SMTP id j19mr1518897pgh.6.1541981633467; Sun, 11 Nov 2018 16:13:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981633; cv=none; d=google.com; s=arc-20160816; b=FR1G2btn5L/gjbbEbOjlr7IMo8+IrfjQiiUnZtO2NLsRyJXm4BKhlYRohosO69BcJf WYdZb00N4x3MfKZb2AgXQ1IgU9F6fW6Cwplx2HiVYvH+sKpaDyc78jPBCNIm4UsLnGs0 Mx8v3Yj3f8ertl08w6QXI/0BJf8sop9ZUhnqMuqjowpU+qGmVhwJ+Ejq+HNFm4t0x3Hm +E83EWM0BVxwtJX7l4ns+6RhlDgX/kPRsY08TXKaQtMfcRc0LWBvWpfBLfsTKdHBWpWI fsBd30fBXgJMQ1Cjqonf2k6xQ+e1Q2LnoBINhZ0BGwGO3ayWrCE7FT83cLlWf02IEwLp mQ/g== 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=AmSCznKX9MMY2uu6Uh9PrkJGbvf0GqpUh0BFxOHpP9c=; b=lO/9ymnrp/3Cc+gp5MgYaoggf67zhkd+CfNGhO41rkFEqrR7Y2We+dqxnBqtEKpddP bQnfAI5ZGAvhRF1x583XQBi/didhpX3yt9slyiDwE+Pk4EWNwUwu2Zk1mgQ7nWxiJZHw sKDINSh/Dk/cdmuOPRgaWPbzB+Z4KuvTTJa2TjXkb3M2jUm5aYGBYPmLQEj3ZoNmcTA+ PLE6IADWYwjS22BzeGPLu3ahdQsKJyLUgHFItTqpXXmgBXmOZETnKt6byGjGaKX3lSXB iAzJuEQZ5ctjNToU0j5HHLhQBAi+mifCqAGYRaL3Y5ugZTTWWdiE+oJXmJ73yms8SNF3 HIfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=raSMigKZ; 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 g67-v6si7511379plb.163.2018.11.11.16.13.38; Sun, 11 Nov 2018 16:13:53 -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=raSMigKZ; 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 S1731083AbeKLKDq (ORCPT + 99 others); Mon, 12 Nov 2018 05:03:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:59948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730420AbeKLIRQ (ORCPT ); Mon, 12 Nov 2018 03:17:16 -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 F1B242154B; Sun, 11 Nov 2018 22:27:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975241; bh=q7opT+EaDE7aYma98OrY3+zku8FzLbvUjxF78nU/hkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=raSMigKZH7TMRS3j8m+OgkGvxhpnssa+C8c0tzHtA99j26kJ4nZs+Xyxx7fzGvWr3 +f/7Q8wetFGKaSD1JVOK2RSrMPdvUSlyOvUqmG6mHV1lXJS8pq504LLoJreCbebKrv 5AsqOg155kJyZxZuSQ2jVoQYk/g2mluSQKaXomDY= 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.19 084/361] mtd: rawnand: atmel: Fix potential NULL pointer dereference Date: Sun, 11 Nov 2018 14:17:11 -0800 Message-Id: <20181111221631.682136291@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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/raw/atmel/nand-controller.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/mtd/nand/raw/atmel/nand-controller.c +++ b/drivers/mtd/nand/raw/atmel/nand-controller.c @@ -2063,6 +2063,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)) {