Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9086862pxu; Mon, 28 Dec 2020 06:18:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYSZoPjI38pNkELIWocjfTWhXUeDjlSQLIJYrpWrRnZoQL8DoEpo1F9lAFAIMewbYR9jKe X-Received: by 2002:a17:906:a011:: with SMTP id p17mr41188530ejy.30.1609165125900; Mon, 28 Dec 2020 06:18:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165125; cv=none; d=google.com; s=arc-20160816; b=D9O8J4mE9QCGcbPXkYWHwb/0p54t4qTSDj5DhBeM1l3V4dR2qbqoPdVNJVrGnpPV+1 kBmDzqvzXoIdE+FydM7GVpI5+t6PHSeiqxgX2Ctg1/JtXXTN7DUMATlIVrGPJ8+VSSCY wa34D42L7RUE8HTAOqtq7OMYal7ejxqoFTPa4MePwG0bpWOtr3caujABKSP3y0eJn6kI /h1TotRigkg2wAIJpNFv+quDhZxebbtPMHoj01Fl21F5eiIqtNu0BxPYCB/JF6lbJBED xFOVGyLdfpnHZEkKRxkwHJXm3CqMrOZOO+8AZXHHDe6J5I7Hnb955zuw3sP6Irzw54ll pVIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Uy+iJw40r9lYKZ2fQUJFsAHiBzew8QAlJdlw83+sBSU=; b=q65QlU9D1twh9dqOmg76sYR1XaGBP8usfi0tGt2krQP6N1G6uVRMym4RtHVfWM3he1 jz/eiNgWkWiQ0hdL5TlhG6GZPM75ewvlnNM9pX+u9X1TA1LM7OcnOmyS5+3Rh/02oJjL 2BUdPrLqOjD9IacOTw6QNVnK6yy1mU1CaXNde//KZYmBdwzJJhnEWljWMhCgKoo4owcd P5tZ0sB961xLQ1YW6DkJZ2EgnjukoYU47O480K3xhAABQaUQUoQkBipvlu6X8Px5G0Yd 1F2NJEG1nGfp+ABKSih/jIS/DoZ3bG+mo3vgIwvHbdmxsLrVf3iUqQ7EmeYrYEggI0xu zE6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mvr6oNHw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si18181206eje.526.2020.12.28.06.18.21; Mon, 28 Dec 2020 06:18:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mvr6oNHw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440473AbgL1OOn (ORCPT + 99 others); Mon, 28 Dec 2020 09:14:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:49528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440459AbgL1OOl (ORCPT ); Mon, 28 Dec 2020 09:14:41 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 28BC322583; Mon, 28 Dec 2020 14:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164840; bh=tphTNjRLSl3fsJBkdTOwUuY0O+F+ZYTjdTi7eEsGz7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mvr6oNHwUVOu0VYtSMgSAyoLMlAgsgPwdcPpffIJQmkxlf4xbN8f2pv5kOl10gmG8 seo8nOJU9yilbHcsEjnvJmIRXDcKnIylXcKr+nIoDZYAf55xmjdmsm9Trf2xelSMBl 5UkQhd+uldQ09jLihw1Wx440hcoeYq+P1fFhkELM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Changzhong , Paul Cercueil , Krzysztof Kozlowski , Sasha Levin Subject: [PATCH 5.10 318/717] memory: jz4780_nemc: Fix potential NULL dereference in jz4780_nemc_probe() Date: Mon, 28 Dec 2020 13:45:16 +0100 Message-Id: <20201228125036.269677844@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Changzhong [ Upstream commit 4bfa07300b9334b487ed4f3d4901c35ebb31b7ca ] platform_get_resource() may fail and return NULL, so we should better check it's return value to avoid a NULL pointer dereference a bit later in the code. This is detected by Coccinelle semantic patch. Fixes: 911a88829725 ("memory: jz4780-nemc: driver for the NEMC on JZ4780 SoCs") Signed-off-by: Zhang Changzhong Acked-by: Paul Cercueil Link: https://lore.kernel.org/r/1607070717-32880-1-git-send-email-zhangchangzhong@huawei.com Signed-off-by: Krzysztof Kozlowski Signed-off-by: Sasha Levin --- drivers/memory/jz4780-nemc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/memory/jz4780-nemc.c b/drivers/memory/jz4780-nemc.c index 3ec5cb0fce1ee..465ea92990d7e 100644 --- a/drivers/memory/jz4780-nemc.c +++ b/drivers/memory/jz4780-nemc.c @@ -291,6 +291,8 @@ static int jz4780_nemc_probe(struct platform_device *pdev) nemc->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; /* * The driver currently only uses the registers up to offset -- 2.27.0