Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2199109iof; Tue, 7 Jun 2022 23:00:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw91D38Er0f+WHQXo324svURlXmtAx0O0bJghlKa8nLAHogWJ2u4r/8BffjLs5TL9wEFsog X-Received: by 2002:a17:902:ce89:b0:167:6117:f905 with SMTP id f9-20020a170902ce8900b001676117f905mr20192043plg.41.1654668001668; Tue, 07 Jun 2022 23:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668001; cv=none; d=google.com; s=arc-20160816; b=k5Zq2Q9Y6PGbovXVK7C8Qw+Or0lp7xa8eFI8Cxj1oQgJUOJvs+3vZYYCi6CvSE1R6v TglATjVquuUVuWU7nyHr+OiiRY2zmD3fLjGACuCCdepg6ntojBHRrfH2dZx5v6ZRxZ8d OuAqNsfEFkcFyBo0R+GZoJQcUFGJP63xPfPSGRCG0Bnh7LPdQnUKIt+i4KSeunJjIga6 GJaQRVQGickWW93w23paobsPUPBBdzNtAub7uwOJyYPToGKSR9JTYnqcR5EWVYuYayUM 14P2IT19aa+/ly1cNg0vsMGI1uXVkOw7lhAhADK/cwiisXv51LN8sag1BFIBfbZ9InXG tfSg== 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=aEJJMy1JrV9kGCHiqmVyOXrVImh+I5FDQEbeV0ZxjHplhvPl7QG8A9GYxXpAL84qIu cgkScVyEYV5C/VrWVg5sdBjsdhhOEnIcl/8YKafDZArPYg85BlYyc6dZssAfTVVrLDpS bZ/TdwRu8pgMP/Qjrasr5rfpL/Ar8OfUDlwB5AwRsveeSsJs+LSQM4mIelh6KdrBPkBI 5f/7EI7i9NfNWDl5nZKuhRMV0Qt9mIyCKvgvZrripaVY7/3MKgfx2Oomeo7WIXja3hsk eg98ZiXtI1QKOAr5+qmUvxzvO4pQS8Zcj3KIMXNgv85RYIKd+40suhLC13Rhqc936dCR hXmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nYN3m9ga; 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 oc3-20020a17090b1c0300b001e4dad046dcsi32245861pjb.179.2022.06.07.23.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:00:01 -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=nYN3m9ga; 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E2C4136C0D; Tue, 7 Jun 2022 22:25:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442491AbiFHBGw (ORCPT + 99 others); Tue, 7 Jun 2022 21:06:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382517AbiFGWDU (ORCPT ); Tue, 7 Jun 2022 18:03:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA8A8252256; Tue, 7 Jun 2022 12:15: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 ams.source.kernel.org (Postfix) with ESMTPS id 549DDB8233E; Tue, 7 Jun 2022 19:15:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFB8BC385A5; Tue, 7 Jun 2022 19:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629318; bh=7C4cWSV1faZyhZGcY7GBV07+JeoEX0fJB6r7GfbLyME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nYN3m9gajBwX2/3j7v0AwF8xEszF4pNYcjh56LV98RYPJSmqNGF6Aha8eUTgl8F1K jtTvUeHNDKxY+6sbQclxqvdk5oj0G0stRCe1XerEOwfFgIPrLrpKHLObFsOz6aafSJ RLbFMFfv5AgGz3XivU0vR1EVGeSd4Ips/qgtKWdE= 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.18 649/879] mfd: davinci_voicecodec: Fix possible null-ptr-deref davinci_vc_probe() Date: Tue, 7 Jun 2022 19:02:47 +0200 Message-Id: <20220607165021.685648500@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 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