Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4713186rwl; Mon, 3 Apr 2023 08:37:10 -0700 (PDT) X-Google-Smtp-Source: AKy350YesdoXY9PFbqkZ7VGQ3HYFnk9Eh6FUku1CLYCXoz+6l8zkiwIK/+shl4qDcNQK5DkB7zzM X-Received: by 2002:a17:90b:4f4d:b0:23f:7c82:2463 with SMTP id pj13-20020a17090b4f4d00b0023f7c822463mr40318008pjb.9.1680536230012; Mon, 03 Apr 2023 08:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680536229; cv=none; d=google.com; s=arc-20160816; b=z9WST4u8yDmwyRfxk6TiEHKzVryTLQI4b6h3mPUBVxVpAKE7qpMWcl2G6joKmefi5l LqxRismKqKVOluxXQNjwFrmWRrtmLlycRY6BuyytTaX7Qv2qrLlBoawHXZ2pDUgwrBme 1Z0SncJ1QrI9dn0ndcdG+82R9rK8JNIMVezvwUYvIFEVhSzqsYIoO6+v79JXcBOgTGnw /UxDzdzBOZnXqMLlGZJfiH6hwtr+kEYKG42HFwM4mJQWb4+1/2eIk5+NYYn3ckU+YP5C 8ySI93OzmzF11QrwJeZRe2vw2i/TdMCJQzfOT1tnQlE/0zSkqh/E9m49FLOpzO3DaBiR d14w== 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=v3gJOIjX5KshTXWHspnr0R2ndpbw1a0qCpva4Im63bo=; b=AfPir7de0ovF/JfqVg4z0OSN5YMz81F6Tib/ejqTHWYkpbqXr/ZhriTjcFChcjVbHI 4ulENewXJj6Z9msDJ/J32JIUeYSJvsUa22sNVP2bQaQ9s5v4V4zj2N4ss26nN1rgwgUs 8BPxi7OUmt74rSustFrrU71DCWOUQJ5YeXB3R4sBBJEWJv840s3DcAtjIzlwCiPJFo/p oH+WOleyBFT4WzbKIGmw5uWldhgGgebtu8hd5m3X7dgl4vZz1FwHG7V9YCmHRY0Yk15t QjH3Y7ZvjaXdshQWH7T8TpGGfnvJ3+5bi00AVuJyDIOu/YOxzFQ6gkdeDHItTCRGGqAM pYxg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lt15-20020a17090b354f00b0023676bd55d1si12359118pjb.94.2023.04.03.08.36.58; Mon, 03 Apr 2023 08:37:09 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232831AbjDCP3E (ORCPT + 99 others); Mon, 3 Apr 2023 11:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232807AbjDCP3A (ORCPT ); Mon, 3 Apr 2023 11:29:00 -0400 Received: from hust.edu.cn (mail.hust.edu.cn [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D14BB10E7 for ; Mon, 3 Apr 2023 08:28:59 -0700 (PDT) Received: from LAPTOP-6NFQSDTK.localdomain ([10.12.182.145]) (user=yll@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 333FRJ5h024979-333FRJ5i024979 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 3 Apr 2023 23:27:24 +0800 From: Liliang Ye To: Shengjiu Wang , Xiubo Li , Fabio Estevam , Nicolin Chen , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Dan Carpenter Cc: hust-os-kernel-patches@googlegroups.com, Liliang Ye , alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] ASoC: fsl_mqs: move of_node_put() to the correct location Date: Mon, 3 Apr 2023 23:26:47 +0800 Message-Id: <20230403152647.17638-1-yll@hust.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: yll@hust.edu.cn X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS 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 of_node_put() should have been done directly after mqs_priv->regmap = syscon_node_to_regmap(gpr_np); otherwise it creates a reference leak on the success path. To fix this, of_node_put() is moved to the correct location, and change all the gotos to direct returns. Fixes: a9d273671440 ("ASoC: fsl_mqs: Fix error handling in probe") Signed-off-by: Liliang Ye Reviewed-by: Dan Carpenter --- sound/soc/fsl/fsl_mqs.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sound/soc/fsl/fsl_mqs.c b/sound/soc/fsl/fsl_mqs.c index 4922e6795b73..32d20d351bbf 100644 --- a/sound/soc/fsl/fsl_mqs.c +++ b/sound/soc/fsl/fsl_mqs.c @@ -210,10 +210,10 @@ static int fsl_mqs_probe(struct platform_device *pdev) } mqs_priv->regmap = syscon_node_to_regmap(gpr_np); + of_node_put(gpr_np); if (IS_ERR(mqs_priv->regmap)) { dev_err(&pdev->dev, "failed to get gpr regmap\n"); - ret = PTR_ERR(mqs_priv->regmap); - goto err_free_gpr_np; + return PTR_ERR(mqs_priv->regmap); } } else { regs = devm_platform_ioremap_resource(pdev, 0); @@ -242,8 +242,7 @@ static int fsl_mqs_probe(struct platform_device *pdev) if (IS_ERR(mqs_priv->mclk)) { dev_err(&pdev->dev, "failed to get the clock: %ld\n", PTR_ERR(mqs_priv->mclk)); - ret = PTR_ERR(mqs_priv->mclk); - goto err_free_gpr_np; + return PTR_ERR(mqs_priv->mclk); } dev_set_drvdata(&pdev->dev, mqs_priv); @@ -252,13 +251,9 @@ static int fsl_mqs_probe(struct platform_device *pdev) ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_fsl_mqs, &fsl_mqs_dai, 1); if (ret) - goto err_free_gpr_np; - return 0; - -err_free_gpr_np: - of_node_put(gpr_np); + return ret; - return ret; + return 0; } static int fsl_mqs_remove(struct platform_device *pdev) -- 2.34.1