Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2831463pxv; Mon, 12 Jul 2021 03:02:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVm/N/qc+FiE0aNXzB/JWMqUSJSshwqQeMZ02X7Po/CSlgcfgnjT1Cd86c7HSN1cyolsUi X-Received: by 2002:a92:8750:: with SMTP id d16mr20541497ilm.281.1626084150603; Mon, 12 Jul 2021 03:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084150; cv=none; d=google.com; s=arc-20160816; b=Yh63PT/PlHJG4aIyVHBHUSUMoFmBYDrYyGCvm55FlT4c63iaHz3OnKI0c/M6ZrlO6H F+ot/+2A8KcjkdoVLM+7n3NyB7WU90CgF6brENrePhsoJnKT0LzZP6FrgbTQuZX8mOXL K8jyq+MsU3yTU+HBuwLhNMkblCAWCWAvmX+fkhmzRG644+ik0EYr+C/s5EBm+kSQnwDE eTBGSWI8YWpL9Mi+caO9osQ6NU41aMwC5AQlMZupmqxXBh85tVTIHW+r+Cw0235RtQOA 6ge091JGF7vH6bWAFkYQXYf5Y1gISi2+7bR/FISe7FTFqf8ywJpJegV1vF1WGMxt3eLh GJJQ== 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=dnpBae3kpc+bov9mFkLS1t90Mozrr/mlHboORA3krdk=; b=ASITHHcUUjs8pnZVNOIcdjXQtCD/RkoL9Qtgn/g/2ARZ6Ks0+6YBBN9Y/v541o+7+q c23kciSc7tsGPLs7A00WHo5rcdFDkspJtcCusdZDPG/kFXxQ+Ny1zb+jedGX5CHiXEa7 6G/kYDqav277YgaqLJH+mV2qGI4AhRfybc9aA2Q89k29DQXFq3HAWYQ6vN6L0+S8RlwS u4Ca46b9sRAHja5c2gIV3l7XZprY4pMn+cBCzxXp17RxTe07GEDyvl/KXJBlVpUERh7C 4jB31sWes8VxHimoeS15Ft6gq50ur817E3aFt8F8SGOb2pyBVYNP8PACVVnCIB1zPVnd B4Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YylGnmXp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si16572186jar.0.2021.07.12.03.02.18; Mon, 12 Jul 2021 03:02:30 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YylGnmXp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243655AbhGLHQz (ORCPT + 99 others); Mon, 12 Jul 2021 03:16:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:50398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240075AbhGLGup (ORCPT ); Mon, 12 Jul 2021 02:50:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5701D610D1; Mon, 12 Jul 2021 06:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072476; bh=B1cRgG21SG42hJAXqPpoRpPtrFu/zmb2kdAhWers4MQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YylGnmXpjzFFUhFUdUAySXf+P3xxaXgZdb5VwoSsNi/O+6JhCev8t9hnI4yDM0BnC 7aS8uddrTo5W6aRiuYopuybZMZI+LOrKizYrDRtv/cHiXMHIj/lSuuSUd8/qN2DxSv HJ1fyLt8QbFdnl3Qro+lsc7H+cDTL3N/raH3QROM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Mark Brown , Sasha Levin Subject: [PATCH 5.10 509/593] ASoC: mediatek: mtk-btcvsd: Fix an error handling path in mtk_btcvsd_snd_probe() Date: Mon, 12 Jul 2021 08:11:09 +0200 Message-Id: <20210712060947.889306315@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET [ Upstream commit b6052c3c7a78f5e2b9756c92ef77c0b56435f107 ] If an error occurs after a successful 'of_iomap()' call, it must be undone by a corresponding 'iounmap()' call, as already done in the remove function. While at it, remove the useless initialization of 'ret' at the beginning of the function. Fixes: 4bd8597dc36c ("ASoC: mediatek: add btcvsd driver") Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/0c2ba562c3364e61bfbd5b3013a99dfa0d9045d7.1622989685.git.christophe.jaillet@wanadoo.fr Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/mediatek/common/mtk-btcvsd.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sound/soc/mediatek/common/mtk-btcvsd.c b/sound/soc/mediatek/common/mtk-btcvsd.c index 668fef3e319a..86e982e3209e 100644 --- a/sound/soc/mediatek/common/mtk-btcvsd.c +++ b/sound/soc/mediatek/common/mtk-btcvsd.c @@ -1281,7 +1281,7 @@ static const struct snd_soc_component_driver mtk_btcvsd_snd_platform = { static int mtk_btcvsd_snd_probe(struct platform_device *pdev) { - int ret = 0; + int ret; int irq_id; u32 offset[5] = {0, 0, 0, 0, 0}; struct mtk_btcvsd_snd *btcvsd; @@ -1337,7 +1337,8 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev) btcvsd->bt_sram_bank2_base = of_iomap(dev->of_node, 1); if (!btcvsd->bt_sram_bank2_base) { dev_err(dev, "iomap bt_sram_bank2_base fail\n"); - return -EIO; + ret = -EIO; + goto unmap_pkv_err; } btcvsd->infra = syscon_regmap_lookup_by_phandle(dev->of_node, @@ -1345,7 +1346,8 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev) if (IS_ERR(btcvsd->infra)) { dev_err(dev, "cannot find infra controller: %ld\n", PTR_ERR(btcvsd->infra)); - return PTR_ERR(btcvsd->infra); + ret = PTR_ERR(btcvsd->infra); + goto unmap_bank2_err; } /* get offset */ @@ -1354,7 +1356,7 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev) ARRAY_SIZE(offset)); if (ret) { dev_warn(dev, "%s(), get offset fail, ret %d\n", __func__, ret); - return ret; + goto unmap_bank2_err; } btcvsd->infra_misc_offset = offset[0]; btcvsd->conn_bt_cvsd_mask = offset[1]; @@ -1373,8 +1375,18 @@ static int mtk_btcvsd_snd_probe(struct platform_device *pdev) mtk_btcvsd_snd_set_state(btcvsd, btcvsd->tx, BT_SCO_STATE_IDLE); mtk_btcvsd_snd_set_state(btcvsd, btcvsd->rx, BT_SCO_STATE_IDLE); - return devm_snd_soc_register_component(dev, &mtk_btcvsd_snd_platform, - NULL, 0); + ret = devm_snd_soc_register_component(dev, &mtk_btcvsd_snd_platform, + NULL, 0); + if (ret) + goto unmap_bank2_err; + + return 0; + +unmap_bank2_err: + iounmap(btcvsd->bt_sram_bank2_base); +unmap_pkv_err: + iounmap(btcvsd->bt_pkv_base); + return ret; } static int mtk_btcvsd_snd_remove(struct platform_device *pdev) -- 2.30.2