Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2272464iof; Wed, 8 Jun 2022 01:04:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYQAFQRSIKqRbMt5KeeoG2pDk5sEK/EBmjgGv3ycLXkPOXw9LpDq+/1XNFvh9qj1qSFPVI X-Received: by 2002:a63:1f22:0:b0:3fc:b45d:2c83 with SMTP id f34-20020a631f22000000b003fcb45d2c83mr28687023pgf.69.1654675470582; Wed, 08 Jun 2022 01:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654675470; cv=none; d=google.com; s=arc-20160816; b=J7SEKedwWu6GLD5H9uMA3RKG2VSBTXwKBJpFcNG7uSCIiSHat9d8EX/brcz7VIadeQ wtvziIyidWK77MEeGJIVoJ/2o2tlJigPTs2P3AWhnO8AlBoBrDHrRzjRfzKmha7+wopy TLlNkf+vR+WI7QljaTNG//W7FfldruJU+/TLKxGKl/pFtVC6oC2G8taTNJKL3AwO6Xi2 aOEhUqvnVQggi723eNBAEiIeBq9Ni+1MNWBjEtfnRyAV2kP3zvzphgW5trN5eaJ7Awfl tUToPjc+jlP6TY10aeMHd3jJlXWuLMopWJ/jvssIb2X5I1I5GbLsezNxpjdZ+/tV/vJq wJGQ== 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=2v+DDDc0T2ROMmHTt4v5KpeBN9BbG4efE9M20V0dWKY=; b=ER2t1qfuuYb3UcudKGvKpbEWmHFy8x6kywA6MvrS8x8+qHsrEpLmDCpZiToImM6JfJ 71mUfRNN6NgVq0nN9ywhDwcL2Afds7Fd34SXSNObPBD+iY5YeeISyqKvtpUWivBPxYA/ 4T715kGfOmi8+//fajyPFBfr72AXucrmEC2cIMXr1HiF3IKWr35y8bRww1/85lDvMLYH t9+LqhWRDBQnU132KixDNznqcnmxwfH0ULI8VPpShz4orTIcV6ntiMM0yJ3RxWeAhPfA h5oh56lSsUJ0Agx8OMEvI+u8zgtzOAQMjcTGgc0NvN7oI1LemTKeIAFIDjQlkuGS/iOv iLjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RJHxzeuT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i197-20020a636dce000000b003fc2c0d5780si26486138pgc.298.2022.06.08.01.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:04:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RJHxzeuT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8FF56237CF3; Wed, 8 Jun 2022 00:34:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349049AbiFGRzb (ORCPT + 99 others); Tue, 7 Jun 2022 13:55:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348720AbiFGRgn (ORCPT ); Tue, 7 Jun 2022 13:36:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5807B11825; Tue, 7 Jun 2022 10:33: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 ams.source.kernel.org (Postfix) with ESMTPS id 35618B822B3; Tue, 7 Jun 2022 17:32:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E8BAC385A5; Tue, 7 Jun 2022 17:32:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623153; bh=7C4cWSV1faZyhZGcY7GBV07+JeoEX0fJB6r7GfbLyME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RJHxzeuTTkxxE0t0nvEOPDsTy6Eh5tdPei1aRGQsMIWKFCIMV5UfDraQrs9x6Le6A LocASjJwETTmvb0ZXc4F3SnoXVMjx76epFo81RhLX7d+qrZH7RAfuV4gC88XUeWUbt 3QHLJFgMNhLDvp5tJDnBnINPniBjDMDmHrn1UJec= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Lee Jones , Sasha Levin Subject: [PATCH 5.10 314/452] mfd: davinci_voicecodec: Fix possible null-ptr-deref davinci_vc_probe() Date: Tue, 7 Jun 2022 19:02:51 +0200 Message-Id: <20220607164917.916652073@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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 311242c7703df0da14c206260b7e855f69cb0264 ] 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. Fixes: b5e29aa880be ("mfd: davinci_voicecodec: Remove pointless #include") Signed-off-by: Yang Yingliang Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20220426030857.3539336-1-yangyingliang@huawei.com Signed-off-by: Sasha Levin --- drivers/mfd/davinci_voicecodec.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/mfd/davinci_voicecodec.c b/drivers/mfd/davinci_voicecodec.c index e5c8bc998eb4..965820481f1e 100644 --- a/drivers/mfd/davinci_voicecodec.c +++ b/drivers/mfd/davinci_voicecodec.c @@ -46,14 +46,12 @@ static int __init davinci_vc_probe(struct platform_device *pdev) } clk_enable(davinci_vc->clk); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - - fifo_base = (dma_addr_t)res->start; - davinci_vc->base = devm_ioremap_resource(&pdev->dev, res); + davinci_vc->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(davinci_vc->base)) { ret = PTR_ERR(davinci_vc->base); goto fail; } + fifo_base = (dma_addr_t)res->start; davinci_vc->regmap = devm_regmap_init_mmio(&pdev->dev, davinci_vc->base, -- 2.35.1