Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2131816iof; Tue, 7 Jun 2022 20:48:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNqg1FH1s562Luc8amr37cxF3hMlw6Un4fmb5M5KTwcSEIG55eAhpYEe9Fw+HOW8fc+fKP X-Received: by 2002:a17:90a:5301:b0:1e8:41d8:d0f5 with SMTP id x1-20020a17090a530100b001e841d8d0f5mr25862529pjh.175.1654660103937; Tue, 07 Jun 2022 20:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654660103; cv=none; d=google.com; s=arc-20160816; b=miI+xZizc/AA24ec4Mi8SAo8LU0rBthrNbKLs+uAdDCXrWNC0RhZTpXFY9WLdmdbeW pHb7j6c6UojSS8/Cp3vAkvEsJ64ProxcU1o4/ZD1UUT3GAiJQkhN0IE+oBFZ7AuW56it 5DNiR6aagHfvZMx0PUxbZpdfIUIfIwk8+V5taTL/ks9yEpOiALvRTLy3AjhkNFaPQb2d GfL4gOaMs+7bkrN00D61yW9dpJrcQ18pUt+X+C/k13scpRE6TwwF5pdNsjv5YENJ0zc8 gBTAY/9tlySMs3C1Y763J8MuiYPsPeWY1Yug1QCFYo0rS0PCBOYLZuiDJqhRVtGddQF0 nafg== 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=8smGoWWRWpycwIFQjBsmK8e5rBVpdbB/XPchftGE1Qs=; b=k25JOzwLKXZy+icHxQqQQD5hncZCUmSD2p3NqoU/Ve6/nUfoBj9OwTN8Mb1SYtmWg1 brZh2wlbHSHVc8N4UYj2aFKc0L6eNeKp/U4uZ8Fx77ThYDpbV2ZYAzpSdBVnV6v1c0aQ rK03UFZtsg9VnKsSH94UM7N5vXJ/V8zsz+DWXWycSB0KCKcqrzhjOnOVUo7yAINytkL8 boMm70hk00mEOeVANlII1irrC7GfGtJy8kaW2btYCyIQ77Wh1JE5y+KP65iUF9sOp26h xlD0mRxV6HHCEy04tmBFaLHnPY0Y+8B0795+WPWRNfxv2fxTobCIUY6m/oGqvL03HljG OgUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w041QQuW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id lx16-20020a17090b4b1000b001e34176705esi2024215pjb.95.2022.06.07.20.48.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 20:48:23 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w041QQuW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BB2892FFA9A; Tue, 7 Jun 2022 20:06:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380242AbiFGWWL (ORCPT + 99 others); Tue, 7 Jun 2022 18:22:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380687AbiFGVQl (ORCPT ); Tue, 7 Jun 2022 17:16:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 130C521F9A3; Tue, 7 Jun 2022 11:56:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 925A36176D; Tue, 7 Jun 2022 18:56:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2CCCC385A2; Tue, 7 Jun 2022 18:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628164; bh=MzavRj9nrP27S+bq6CPB0yuwsmyvhj3CJKBoxHtwgwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w041QQuW6VPPKnz6xlCcxmlN1O2RT79aXuY/nCUxIrrkqJuJUTAdJYVrZRs5hDYvf KWNRTjT2tWaGmMNT9H3Od/Q2Czx8h0cYxajiw/IxJK4QXYCbxKX+XMyP6mHwfrzjej u3SeK4M+0ioHyXeQwdlA322fM1y/k3+s4lNCInUY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Geert Uytterhoeven , Sasha Levin Subject: [PATCH 5.18 228/879] pinctrl: renesas: rzn1: Fix possible null-ptr-deref in sh_pfc_map_resources() Date: Tue, 7 Jun 2022 18:55:46 +0200 Message-Id: <20220607165009.471207468@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang [ Upstream commit 2f661477c2bb8068194dbba9738d05219f111c6e ] It will cause null-ptr-deref when using 'res', if platform_get_resource() returns NULL, so move using 'res' after devm_ioremap_resource() that will check it to avoid null-ptr-deref. And use devm_platform_get_and_ioremap_resource() to simplify code. Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20220429082637.1308182-2-yangyingliang@huawei.com Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin --- drivers/pinctrl/renesas/pinctrl-rzn1.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rzn1.c b/drivers/pinctrl/renesas/pinctrl-rzn1.c index ef5fb25b6016..849d091205d4 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzn1.c +++ b/drivers/pinctrl/renesas/pinctrl-rzn1.c @@ -865,17 +865,15 @@ static int rzn1_pinctrl_probe(struct platform_device *pdev) ipctl->mdio_func[0] = -1; ipctl->mdio_func[1] = -1; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - ipctl->lev1_protect_phys = (u32)res->start + 0x400; - ipctl->lev1 = devm_ioremap_resource(&pdev->dev, res); + ipctl->lev1 = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(ipctl->lev1)) return PTR_ERR(ipctl->lev1); + ipctl->lev1_protect_phys = (u32)res->start + 0x400; - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - ipctl->lev2_protect_phys = (u32)res->start + 0x400; - ipctl->lev2 = devm_ioremap_resource(&pdev->dev, res); + ipctl->lev2 = devm_platform_get_and_ioremap_resource(pdev, 1, &res); if (IS_ERR(ipctl->lev2)) return PTR_ERR(ipctl->lev2); + ipctl->lev2_protect_phys = (u32)res->start + 0x400; ipctl->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(ipctl->clk)) -- 2.35.1