Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2960371iob; Fri, 6 May 2022 14:27:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOK6lQQ/qQGSXn2cYavlcffFa+zgA3HSeEYZy4bimEVLxccVRR8ZBzDCJ8rK6In5hpu+Z8 X-Received: by 2002:a17:906:2518:b0:6f4:d34d:c202 with SMTP id i24-20020a170906251800b006f4d34dc202mr4763809ejb.710.1651872454079; Fri, 06 May 2022 14:27:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651872454; cv=none; d=google.com; s=arc-20160816; b=wBlE5PW4R3SzZwJk10Ix7FuknlXVINCgbu+7UE3Qr6zV1or8e6G5+92OP4wgs/y7eF YzHuNmuSv/7+uptYVt/1eQQoeD1W6W1ykK5Q9Nz9wl2tWQNMFhBrK/xY07LrN1YPRYq9 AkXpTmMj/hQdG/eSwZX8vesnWSon+4bAdMheu9BiY36O1PmePQUgGAd8kkM5buqLBpVW 9sD0ikiVy6HvZjgvqtgGbkNs92yPk6h+PEhzM7fNtveTwMmboh7FRki/BYOh+VAKFGag s039f2rm4MDSPnT5URzotaiSuh5rU9TYywujEFrwDpjB/F8dIRaUuTwxqMl3fX6qJecr xTXg== 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=NzanjwtWtkzjKS1jbnT+RGjGeiAm4yZupXznvEo/xbKB57pCbZI6CEvMfGafHIjuEg DEmP3JpCwhSucx8m0rqvLu7l8nxo8tQp6RAM2KqElqQ8POj6nZGl5+vSL5fRn1fWY/Xt 5uVee6YxPeE4n0WFBCuscf9vnOVYkkl8s/cZiFSXYu2Run1VobmxFUfS3yJoSv7TOlWz oif1JA+cxg1H43W4+O/1JDhLyaGD0jcCZ5NICmEGR/hHgOk91jty53PlMedEtdWAyEf8 Oh92xhVJc4e+SfomEfsoXKfrsn1Lm8vtES6LPZ3MY4+ypFhjPA4fhHxPSVCajaJne1NO UgHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gJxzKo1M; 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 hq35-20020a1709073f2300b006e47fac6cfcsi6085995ejc.774.2022.05.06.14.27.09; Fri, 06 May 2022 14:27:34 -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=gJxzKo1M; 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 S1354150AbiEDQ4i (ORCPT + 99 others); Wed, 4 May 2022 12:56:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354274AbiEDQx7 (ORCPT ); Wed, 4 May 2022 12:53:59 -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 28AE6488AD; Wed, 4 May 2022 09:49:20 -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 5ACA061701; Wed, 4 May 2022 16:49:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A97D6C385A5; Wed, 4 May 2022 16:49:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651682958; bh=vzEX6Tq9n68EdutGIw5T+UJNk47l/3TGbuch2cwKSbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gJxzKo1MWeeIn5Zz1VxQdkwGMf/5I4IiKelUWqrWT7OqTAXaAgxjgurckVU5ENzui iRM4fY/mT6ODreu0GUXCwaXxCIHtsrd9zfu3J+IadEIBLXi/fSfHNI8w09z4c+3PJH uGdgqB9XAyyV38/cc7CEvTz9Or/6CuioXR3U2JB8= 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.4 60/84] clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource() Date: Wed, 4 May 2022 18:44:41 +0200 Message-Id: <20220504152932.010530078@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504152927.744120418@linuxfoundation.org> References: <20220504152927.744120418@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