Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1410062pxb; Fri, 21 Jan 2022 18:01:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhqWmGHssIgWJAns7ttuJfNDd2LQs9i66xv82UPFsbDiGlD2/yqyhwavEsy9jphTn2w3ow X-Received: by 2002:a17:90a:4407:: with SMTP id s7mr2307947pjg.126.1642816914049; Fri, 21 Jan 2022 18:01:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642816914; cv=none; d=google.com; s=arc-20160816; b=G/uu66LC0PZxHjPAEnhMVkzEQ/bKwnWNvVJFvEn0BIRyLkHpufi0XZS63S5Ti1d+8K NWX/x3VBgg35zPsal66xP++0R6OEh7eiSM1RrGBt+/JpC2gjHJlogJ5HRiqejybiR6KW FSM5KLXT6tjoItUglN2zpsQCfxJCLujdiLJHLhtQ1Ks+swMrhnZLboGH96nhsQIutNLo /2tUFw+q7cZO3Oes23+tb+LVyn4R5prBFJe1Y9YPTmDfn23OrlpuydJu4HCSTFrbYzOP j34bBlpkKFEgH66JsHSfOf5NtfvefECRkKVNyOrYCB7bSgeWBM7XXJhd3QsPfgGxTvD4 ZQ6A== 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 :message-id:date:subject:cc:to:from; bh=mTDkSBdWLobrvbE6HDedgncORjc4qMCC2kGDUp+x5uw=; b=aK3rWXadPa4RkEdvJm+Bw+1USkbavOOpDkoQBbXHXezj9wz1iUSRe1A5n1/usLEFhr LpcHW5rssWhoM8K6DzS2whYw9LoGu/6mbF7CYFT2ct1ig5AEM4gdZ5srbKVC+dHj97Ar ZoXIQFSAusPxOya6MzTG9QW2NSH3NF9zmU07+K2fx7KemtLi9NybH7U5HdXqVACVPs+F 3Y7/uLT2MrWPPaCH/yS/IUYRHHJWMlxLtSW46kbSlojuhl2w9vO7qQ6GqZP2MvEcscrS aJmRTVJokyom8FpCOtgFaj9MnDDddUrfbOrr2Z1IBGjm5YcZh6n+1j29X9XEuvGYiNIk /i0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e22si1589517pgn.136.2022.01.21.18.01.41; Fri, 21 Jan 2022 18:01:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350609AbiAURLF (ORCPT + 99 others); Fri, 21 Jan 2022 12:11:05 -0500 Received: from smtp21.cstnet.cn ([159.226.251.21]:50768 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229549AbiAURLE (ORCPT ); Fri, 21 Jan 2022 12:11:04 -0500 Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-01 (Coremail) with SMTP id qwCowAB3fZ0I6ephkjS6Bg--.24303S2; Sat, 22 Jan 2022 01:10:32 +0800 (CST) From: Jiasheng Jiang To: broonie@kernel.org Cc: cezary.rojewski@intel.com, srinivas.kandagatla@linaro.org, bgoswami@codeaurora.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH v3] ASoC: codecs: Check for error pointer after calling devm_regmap_init_mmio Date: Sat, 22 Jan 2022 01:10:31 +0800 Message-Id: <20220121171031.2826198-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID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vf C2KfnxnUUI43ZEXa7VUjo7K7UUUUU== X-Originating-IP: [124.16.138.126] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the potential failure of the devm_regmap_init_mmio(), it will return error pointer and be assigned to the regmap. Then the error pointer will be dereferenced. For example rx->regmap will be used in rx_macro_mclk_enable(). Therefore, it should be better to check it. Fixes: af3d54b99764 ("ASoC: codecs: lpass-rx-macro: add support for lpass rx macro") Fixes: c39667ddcfc5 ("ASoC: codecs: lpass-tx-macro: add support for lpass tx macro") Fixes: 809bcbcecebf ("ASoC: codecs: lpass-wsa-macro: Add support to WSA Macro") Signed-off-by: Jiasheng Jiang --- Changelog v1 -> v2 * Change 1. Refine the commit message. v2 -> v3 * Change 1. Make the patch against the latest code. --- sound/soc/codecs/lpass-rx-macro.c | 2 ++ sound/soc/codecs/lpass-tx-macro.c | 2 ++ sound/soc/codecs/lpass-wsa-macro.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index aec5127260fd..29d214f784d1 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -3542,6 +3542,8 @@ static int rx_macro_probe(struct platform_device *pdev) return PTR_ERR(base); rx->regmap = devm_regmap_init_mmio(dev, base, &rx_regmap_config); + if (IS_ERR(rx->regmap)) + return PTR_ERR(rx->regmap); dev_set_drvdata(dev, rx); diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c index a4c0a155af56..9c96ab1bf84f 100644 --- a/sound/soc/codecs/lpass-tx-macro.c +++ b/sound/soc/codecs/lpass-tx-macro.c @@ -1821,6 +1821,8 @@ static int tx_macro_probe(struct platform_device *pdev) } tx->regmap = devm_regmap_init_mmio(dev, base, &tx_regmap_config); + if (IS_ERR(tx->regmap)) + return PTR_ERR(tx->regmap); dev_set_drvdata(dev, tx); diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c index 75baf8eb7029..69d2915f40d8 100644 --- a/sound/soc/codecs/lpass-wsa-macro.c +++ b/sound/soc/codecs/lpass-wsa-macro.c @@ -2405,6 +2405,8 @@ static int wsa_macro_probe(struct platform_device *pdev) return PTR_ERR(base); wsa->regmap = devm_regmap_init_mmio(dev, base, &wsa_regmap_config); + if (IS_ERR(wsa->regmap)) + return PTR_ERR(wsa->regmap); dev_set_drvdata(dev, wsa); -- 2.25.1