Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1160474iob; Wed, 4 May 2022 16:15:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBoJlVjPDlw+8bmyg8glRFYGTX2QTfZZxEeWJ0KRweHud62/Q4DsxpXVVceRAZDhdgwdq4 X-Received: by 2002:a05:6402:268f:b0:427:d90e:86a1 with SMTP id w15-20020a056402268f00b00427d90e86a1mr13687507edd.143.1651706111018; Wed, 04 May 2022 16:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651706111; cv=none; d=google.com; s=arc-20160816; b=fZb9umUk8+4cCdCKrh62Vj8VUqWVdA33498AKoCbqIwd589l9R4K8DP+dBkpDNsicx 6pf0JzKEzqC5TIOox4swfvU6Pg9MuKak8yDnGfTOxqBqqFWmVIF3LGsFChVqKqKzRJNP G8xBPX6HHkgknkiRNj7ttIMbi+ayFMoDXQNPME279hN4S/xpuRw3nB0Dq28nRHw9rdVU TfkRITa+BsDEdVfc0wIvDoGuOLdWG28edFC84deT8AoUTPvH3wKy9Wpgr0hekWQIsuCz tFHq+0bz05no4LRZVXbnkp6MqZgwGePvbO/QGyfFlRptQL93wPibyxJ59jMT1/H33FL6 qH3A== 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=abJ1CFUHPWWe/a1dadFeZx4NpJai5KQEduuMYZGItoQ=; b=P3jo+C+mvzO8NC10thzSFO9fXSnbDPoJRE/yDaw3yZ0gdifnpq53eZ+CoxAd7XhAYf f8pzEBg3QgKtEDG0ZSETRK2j5ft43pct9OqIdBKGCpoCNl8/9njv0FaHVwNYs0ZvHjoH Uf3obVH4F3/JiPUKK3DevdIWRgiAY/7YUOMk0XnxzTVEIGJ4si5xYev4rCo1mxlGfPGX zVH2eb6q1xKm5AR/wIAE+EE14vU28ECmD9ZPDD0RtuWw1QkLczZH9C8ccNNto43B252v LdpR//kiFOXNmSImL1k9fBYd/Jzw+tjcYuh9I2tX9vgFmtT5sc25acNVjyjCtetKDNF7 8woQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y71IOSKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp10-20020a1709073e0a00b006f4408bfffbsi238119ejc.779.2022.05.04.16.14.47; Wed, 04 May 2022 16:15:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y71IOSKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1352237AbiEDR0Y (ORCPT + 99 others); Wed, 4 May 2022 13:26:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353151AbiEDRFU (ORCPT ); Wed, 4 May 2022 13:05:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E75850E16; Wed, 4 May 2022 09:54:14 -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 ams.source.kernel.org (Postfix) with ESMTPS id 9A69AB827AD; Wed, 4 May 2022 16:54:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26102C385A5; Wed, 4 May 2022 16:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683251; bh=vzEX6Tq9n68EdutGIw5T+UJNk47l/3TGbuch2cwKSbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y71IOSKfQjSk+KpJQJBtc9NT637Hka7ODM+v+Z88h43YF/xwbBkwUNpQLVNByefE8 ZlO+OIRdmy5QlEju4W4DbkVLrbzhiRR4RPwElxa85F3cj8NQFGHVxXvOIprxBD06zp InwOoOEcbZekOy+8KZXBrjVXyfFXEKNqC3SkcCig= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Samuel Holland , Jernej Skrabec , Sasha Levin Subject: [PATCH 5.15 104/177] clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource() Date: Wed, 4 May 2022 18:44:57 +0200 Message-Id: <20220504153102.499192036@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 f58ca215cda1975f77b2b762903684a3c101bec9 ] It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Fixes: 7a6fca879f59 ("clk: sunxi: Add driver for A80 MMC config clocks/resets") Signed-off-by: Yang Yingliang Reviewed-by: Samuel Holland Signed-off-by: Jernej Skrabec Link: https://lore.kernel.org/r/20220421134308.2885094-1-yangyingliang@huawei.com Signed-off-by: Sasha Levin --- drivers/clk/sunxi/clk-sun9i-mmc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/sunxi/clk-sun9i-mmc.c b/drivers/clk/sunxi/clk-sun9i-mmc.c index 542b31d6e96d..636bcf2439ef 100644 --- a/drivers/clk/sunxi/clk-sun9i-mmc.c +++ b/drivers/clk/sunxi/clk-sun9i-mmc.c @@ -109,6 +109,8 @@ static int sun9i_a80_mmc_config_clk_probe(struct platform_device *pdev) spin_lock_init(&data->lock); r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!r) + return -EINVAL; /* one clock/reset pair per word */ count = DIV_ROUND_UP((resource_size(r)), SUN9I_MMC_WIDTH); data->membase = devm_ioremap_resource(&pdev->dev, r); -- 2.35.1