Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2585768iob; Fri, 6 May 2022 06:17:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkgNNNfe+qPbTL05EUoF3LfaZLAuZFXWQA6+nkhfHqMTOMIvMyFVwNAoz8pSVjZMdTr8/9 X-Received: by 2002:aa7:db4c:0:b0:428:111c:b6bd with SMTP id n12-20020aa7db4c000000b00428111cb6bdmr3355257edt.318.1651843076302; Fri, 06 May 2022 06:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651843076; cv=none; d=google.com; s=arc-20160816; b=Mbr6+sftxXYsUbKYu2zETkclIewYF98ISOYkbIi/6pPHUpa7cOC5VaPFalZwfS2yp3 DGHmkeJsRhBYNcqWpDkV9RMapJsKWwADJEEW63XnnPwfaBljewqW4CuyX9r7kJsCL4Ak /2XsaeDiYF58/H4x8W2fNXOAyt8+895S5UgAVWEaCgt5UJ3HPe5MekS7prYTapbXk0y2 ARsNMgpUdhflA6u549cGVyTxblnMDuOr7cbxfN1Q39DiL1KQKnBLHfUKVQ07C+Y2lHaX K+obp4NzMuB3wm8e15tBnEjUforX/AZB8gLZBunkRPxZ0FjptR3mem1RSLJsZoQge1qf qDBA== 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=Nvwqm5NPIRyvDeYO6i7LnTupNiEfsAnZEaabR0ZUaABRLzAow/9GBTOti5O+KYOC0q quK54B//Ui99uj3TdSfv7JQlnXHeo3zoeeQ5vSaMPIsHrX7R+4H8N8YIlrO2UKredCfy tqJvOCSls8R6AwyUfAoAGkxY/DWZWphEmYvI1hGCXcWWierRMBGvKg0j+YAEBkoTKCkD 0v+m4f3POKlRZ60G9onyldsPMMUaKA+wH0ggmtbSokjCByxz09fS7kcaNrDgaoZayYtK kKzfgUCXUQ+SH31g6mkGKYbwzdx5iW57SGSlgEKRskGU47sZ48nCIsnEPpnuhPh7wXzB cFRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="FGSxSc/Y"; 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 l8-20020a056402254800b00423f62ce403si4779201edb.571.2022.05.06.06.17.26; Fri, 06 May 2022 06:17:56 -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="FGSxSc/Y"; 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 S1355670AbiEDRIa (ORCPT + 99 others); Wed, 4 May 2022 13:08:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355460AbiEDRAE (ORCPT ); Wed, 4 May 2022 13:00:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 686B64B426; Wed, 4 May 2022 09:51:44 -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 82C6AB827A6; Wed, 4 May 2022 16:51:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 270DBC385A4; Wed, 4 May 2022 16:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683094; bh=vzEX6Tq9n68EdutGIw5T+UJNk47l/3TGbuch2cwKSbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FGSxSc/Y+D+uGB+8ugVCWrUfPJpCLlGVYt/ibmICavk0rH1unVXeBf0+FWlSNmVMC ANhxNJLamxS8Xwzw0Ml8KXAojAk99mCUfxLknJiZvg3ZS3LD+3UKNMC5sdl+34gXGq sHNFgdDwfgGXn6qhciAB1Ma1aYssbYZGiW5E0Nd0= 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.10 086/129] clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource() Date: Wed, 4 May 2022 18:44:38 +0200 Message-Id: <20220504153027.856390255@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153021.299025455@linuxfoundation.org> References: <20220504153021.299025455@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