Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp177948imd; Wed, 31 Oct 2018 16:53:36 -0700 (PDT) X-Google-Smtp-Source: AJdET5fvK5Xivgx69ITSymge2xIiy/djvitYAU1mdJQCkdxL8uncOaR4FtqoQwi4R6ROEGzaMkKf X-Received: by 2002:a17:902:68:: with SMTP id 95-v6mr5386227pla.57.1541030016864; Wed, 31 Oct 2018 16:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541030016; cv=none; d=google.com; s=arc-20160816; b=dPiSUwpsAa9WjUYSdsy5Aljtd+bEExiMSQ56/8Wdn/LvuiLMZQvHMZvPIe42Sgk/jL KoSgZkyrBX7XHX8jT8j2SNEVDhAGB31tBLUb9bVUtAjHEIwYxfI6b+yW94KMLHyDJOnh u+oROvIfo+tSpX5BgVDOPM/Ynp2NxtHD3KowFPQOyrAmAcZXQTfQcYo7IBXfLNxvDTot W+zdWjQokzftDGmOu3RD/VH5j1vvPrafNbluHu/ZJhG8oijI6+w8uxY6mik3CBrxt3iM C2LiQeQ8M4ot6yeOtcPj6mJ8n+WBwvXsE6P47xNC1D40XOk0aLfLcrVMYKnCyr8RqwA7 WOTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Lczi2M8hyfTfLSckSVI2WaloXbSN3BKnEZkx1ob0cB8=; b=TVa8lSq4Ke3JkY3sp75C7R8eBoILkfNcxvFWfWa35llU26MFL13+/OZN6QTrjmUMQX ztlVEvUVAVWpsWAhWrr7Oae+j5LsCet5NKHQKbTYaqDlaqzwCTLXBkV1xSJHYdJ/Y9wg dkFtvQBeOMpwKZowfvHnF6N8g1dMWMD6zyvedwdzFWYK4eV9yhtVoOxmH2DFhhqvXXCD 9d0fGiYzZLDpEkicxpfdIuxy2fpxN89XyR4WSwNZiciEtf7rIUUreBBM9CRFM53PSkgG nNuUeo2i8mNUC1P9tkjl9evYRannClFz/Zy+P8rZK1oI+kwI2NMXm28ISiIkiTQlu0S5 Tajw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oh6WnjZt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7-v6si28711415plp.420.2018.10.31.16.53.22; Wed, 31 Oct 2018 16:53:36 -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; dkim=pass header.i=@kernel.org header.s=default header.b=oh6WnjZt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728275AbeKAIwO (ORCPT + 99 others); Thu, 1 Nov 2018 04:52:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:53350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727945AbeKAIG1 (ORCPT ); Thu, 1 Nov 2018 04:06:27 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4682520664; Wed, 31 Oct 2018 23:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027176; bh=OrQ4pSYmgjMHqbfy6V7rTVsw2y6ag8qBCF+rqljgiiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oh6WnjZtMyiWotv3hWUb/f4n7maxw0Jtne/nOkb2zu2lIb9uQGKHteYpsP5yRsbHQ 4sZu71ko38XwD7aItEgdvASw9jDxVVQJBtHXbvx5uE6iA7deT/tOKL+ir0R0w7iqAx ID0ixklhlmodob6eC6p5rpDIJ7WWQ5v3Vpx1q/i8= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Gustavo A. R. Silva" , Miquel Raynal , Sasha Levin Subject: [PATCH AUTOSEL 4.19 038/146] mtd: rawnand: atmel: Fix potential NULL pointer dereference Date: Wed, 31 Oct 2018 19:03:53 -0400 Message-Id: <20181031230541.28822-38-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 a068b214ebaa..a594fb1e9a99 100644 --- 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(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)) { -- 2.17.1