Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4602454pxj; Wed, 12 May 2021 09:03:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGTDM61ONlST86HNDrUsuDJgbh6btgRij1nesUp3eg71XMWt/ORW60aB81M1EEb4vQTCap X-Received: by 2002:a9d:20e5:: with SMTP id x92mr31854250ota.105.1620835400724; Wed, 12 May 2021 09:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835400; cv=none; d=google.com; s=arc-20160816; b=XxKarxGxkDVP7Or5VHyUsvVHk+mauFl6KJgDcOAMpqCQVE5JTgCxa7kSL8t9Aqfagn i6I69pzArb1U+9KoTt+0NMvegC0KdgTsWRPWyu5SNHKc3c7TiKX8uCjBnlUGvAVQDz2l Ekfc2yD+14S4/Ns1ZTyb08yIRpXgoaecsbQvm9PDwBclkFDw1hzAd4a5xcYcTjSduH28 sw/irri+QqEufAEe+pmHqlgBfFbw1kXzMYwDhLySeBaV3iR8BQ9CpEH4SkZGNU/ZCgxn aPhbRnE+cc/Noz2v9QyzdkDkGot34swTcq7nbTiYlcYOscWlec+BWV2DuschyiJiG8Cb aKsg== 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=942g2fy/1DE8O/a9F3jQ9z5qtvIdE+O2HKrvjVdmi04=; b=gP8UBX/FW3ojkxdUth/+8n0CO9QsfvcTwwMxzfuSU9MmvYK5yEOYF/dcuV3ojpS8iS EYkGtRzahoSanMcHJ3vqnZ6+sH84QonNQ6ncQozV6gfKI/6+72gXIoRXIHsRarTKANmB Lvua8eEQIlygPHl/hdy5BqF+JcHcGLQ8Tw6Ak9RqiXZLvDrolwkQb2MDv5DsL69vAa47 4ef/dSIw4lVHIRSroCzdUdelze3VU/j5b/j3MHfi7ueNx8YD+aky/sXazgNeO4GugxV6 ah4+ZljLwiaLqYAKjqJQzIdLk5ey4cQTOej876Tv4fMjm0CH6d1otDXAkavVN6wj3B+y S+AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PITcFGSu; 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 a9si392982oif.124.2021.05.12.09.03.06; Wed, 12 May 2021 09:03:20 -0700 (PDT) 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=PITcFGSu; 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 S235513AbhELQDH (ORCPT + 99 others); Wed, 12 May 2021 12:03:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:39912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235541AbhELP21 (ORCPT ); Wed, 12 May 2021 11:28:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4C8D561C21; Wed, 12 May 2021 15:13:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832422; bh=FCyMtEtepY+BScjx75cdRn2xsF4wszsybo1Y6hvIoyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PITcFGSuLo6RjDensbOXwz9HGpiQcBhYTi2neMW6REeXnUVWw/NuFFTw5Sy6REjYf QKvaB04GXbKmX07czczS/yxonRrjY1Bp/rnxCkJS/eRqJy9o+S5CRk+mVHdxHWiA6t 6Lk2R9AOdDm6dB/dFlJg+jeCHwFETT57r+a/Ksrw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Kozlowski , Sasha Levin Subject: [PATCH 5.10 256/530] memory: renesas-rpc-if: fix possible NULL pointer dereference of resource Date: Wed, 12 May 2021 16:46:06 +0200 Message-Id: <20210512144828.248550075@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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: Krzysztof Kozlowski [ Upstream commit 59e27d7c94aa02da039b000d33c304c179395801 ] The platform_get_resource_byname() can return NULL which would be immediately dereferenced by resource_size(). Instead dereference it after validating the resource. Addresses-Coverity: Dereference null return value Fixes: ca7d8b980b67 ("memory: add Renesas RPC-IF driver") Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20210407154357.70200-1-krzysztof.kozlowski@canonical.com Signed-off-by: Sasha Levin --- drivers/memory/renesas-rpc-if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-if.c index da0fdb4c7595..1fe6c35b7503 100644 --- a/drivers/memory/renesas-rpc-if.c +++ b/drivers/memory/renesas-rpc-if.c @@ -193,10 +193,10 @@ int rpcif_sw_init(struct rpcif *rpc, struct device *dev) } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dirmap"); - rpc->size = resource_size(res); rpc->dirmap = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(rpc->dirmap)) rpc->dirmap = NULL; + rpc->size = resource_size(res); rpc->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); -- 2.30.2