From nobody Fri May 8 03:08:08 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5A27C433F5 for ; Thu, 12 May 2022 11:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353157AbiELLPW (ORCPT ); Thu, 12 May 2022 07:15:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353086AbiELLOX (ORCPT ); Thu, 12 May 2022 07:14:23 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE8B238D77 for ; Thu, 12 May 2022 04:13:40 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id c14so4502430pfn.2 for ; Thu, 12 May 2022 04:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3SloLfFU8a1Q2HMNHKnLwbt6pwT6BUy9sQ/8OgycCqI=; b=TWkDoQms83WKpuzTNBdzKvhoODw/n2DKAB8PkH+WiozWmeNSuyjVm2KbSvtlMzMYCU 5AfE9yC2bc67wnsu2Z8Vv8u3Af/Zzx8mURws2tXG8nDAjzY6OYZb425+fGXR8DRY6LPV arSq90SoYNx+KnlokAVjO1vz4A8Wz87mIQWyEvLOI0UCBfKL3NQt1u4ln6YGym9EIWej ZiFRbwxPQChV0Bb8ZVLe4FQO06jNZD9Af123ar9N0qMbNk8LMocN60z3oQCYCpzAJx63 imffSCEagiv0jJexube7LgHVJAdDYLcQEPa9aMbEngNzcN1tzHa0Q3mPlseKS7bfJkgZ X4BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3SloLfFU8a1Q2HMNHKnLwbt6pwT6BUy9sQ/8OgycCqI=; b=r5JsPqYsKgIr4e0WaWRWAXQNPKvJRrpxVdlPYtCjRAEjCGfgw/rtRpTLg8Rs5uBTk6 HVhC+2bcyO0Gr4XVYQt1C9pPCoJ0qAch5P6xoFie1c4GHdBJIJoAtTvuiS9ucCpZPtcd iUYuOxFM7GBNdqJTnb9hc7CI1Us87N75MtoTW7unnrDj7W+cCl+N9+3JdngthR4bMUuB +Q5sKVbapHJ02tcsJc/KEAt5I/Kd07Xb/95VLw+ecqi/a1160VRX2fBidYkSBGckrbC7 Eu2jx6HJwySQHf4VoECx017rGVuoqAprUfHGhoAcU+8XtdNL4sznttymRUeVxMD7io0j TOwg== X-Gm-Message-State: AOAM532wh4MCK2mIljMnOagT1RUZdE7BfZWnuozXP9eODWUW7+2zQtwn z/ygoedLIbN6BRgOSnFCqH4= X-Google-Smtp-Source: ABdhPJy/350N6jJC6Z1dMu9/mg4+Nu0BAcptLFnUjKHPNCWQopVS3tO4EUk5mkrlt09q3p5haIZgow== X-Received: by 2002:a05:6a00:b87:b0:510:5e02:79f1 with SMTP id g7-20020a056a000b8700b005105e0279f1mr29558222pfj.80.1652354019644; Thu, 12 May 2022 04:13:39 -0700 (PDT) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id c3-20020a170902724300b0015e8d4eb20esm3605859pll.88.2022.05.12.04.13.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 04:13:39 -0700 (PDT) From: Miaoqian Lin To: Peter Ujfalusi , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: linmq006@gmail.com Subject: [PATCH] ASoC: ti: j721e-evm: Fix refcount leak in j721e_soc_probe_* Date: Thu, 12 May 2022 15:13:30 +0400 Message-Id: <20220512111331.44774-1-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not needed anymore. Add missing of_node_put() to avoid refcount leak. Fixes: 6748d0559059 ("ASoC: ti: Add custom machine driver for j721e EVM (CP= B and IVI)") Signed-off-by: Miaoqian Lin --- sound/soc/ti/j721e-evm.c | 44 ++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/sound/soc/ti/j721e-evm.c b/sound/soc/ti/j721e-evm.c index 4077e15ec48b..6a969874c927 100644 --- a/sound/soc/ti/j721e-evm.c +++ b/sound/soc/ti/j721e-evm.c @@ -630,17 +630,18 @@ static int j721e_soc_probe_cpb(struct j721e_priv *pri= v, int *link_idx, codec_node =3D of_parse_phandle(node, "ti,cpb-codec", 0); if (!codec_node) { dev_err(priv->dev, "CPB codec node is not provided\n"); - return -EINVAL; + ret =3D -EINVAL; + goto put_dai_node; } =20 domain =3D &priv->audio_domains[J721E_AUDIO_DOMAIN_CPB]; ret =3D j721e_get_clocks(priv->dev, &domain->codec, "cpb-codec-scki"); if (ret) - return ret; + goto put_codec_node; =20 ret =3D j721e_get_clocks(priv->dev, &domain->mcasp, "cpb-mcasp-auxclk"); if (ret) - return ret; + goto put_codec_node; =20 /* * Common Processor Board, two links @@ -650,8 +651,10 @@ static int j721e_soc_probe_cpb(struct j721e_priv *priv= , int *link_idx, comp_count =3D 6; compnent =3D devm_kzalloc(priv->dev, comp_count * sizeof(*compnent), GFP_KERNEL); - if (!compnent) - return -ENOMEM; + if (!compnent) { + ret =3D -ENOMEM; + goto put_codec_node; + } =20 comp_idx =3D 0; priv->dai_links[*link_idx].cpus =3D &compnent[comp_idx++]; @@ -702,6 +705,12 @@ static int j721e_soc_probe_cpb(struct j721e_priv *priv= , int *link_idx, (*conf_idx)++; =20 return 0; + +put_codec_node: + of_node_put(codec_node); +put_dai_node: + of_node_put(dai_node); + return ret; } =20 static int j721e_soc_probe_ivi(struct j721e_priv *priv, int *link_idx, @@ -726,23 +735,25 @@ static int j721e_soc_probe_ivi(struct j721e_priv *pri= v, int *link_idx, codeca_node =3D of_parse_phandle(node, "ti,ivi-codec-a", 0); if (!codeca_node) { dev_err(priv->dev, "IVI codec-a node is not provided\n"); - return -EINVAL; + ret =3D -EINVAL; + goto put_dai_node; } =20 codecb_node =3D of_parse_phandle(node, "ti,ivi-codec-b", 0); if (!codecb_node) { dev_warn(priv->dev, "IVI codec-b node is not provided\n"); - return 0; + ret =3D 0; + goto put_codeca_node; } =20 domain =3D &priv->audio_domains[J721E_AUDIO_DOMAIN_IVI]; ret =3D j721e_get_clocks(priv->dev, &domain->codec, "ivi-codec-scki"); if (ret) - return ret; + goto put_codecb_node; =20 ret =3D j721e_get_clocks(priv->dev, &domain->mcasp, "ivi-mcasp-auxclk"); if (ret) - return ret; + goto put_codecb_node; =20 /* * IVI extension, two links @@ -754,8 +765,10 @@ static int j721e_soc_probe_ivi(struct j721e_priv *priv= , int *link_idx, comp_count =3D 8; compnent =3D devm_kzalloc(priv->dev, comp_count * sizeof(*compnent), GFP_KERNEL); - if (!compnent) - return -ENOMEM; + if (!compnent) { + ret =3D -ENOMEM; + goto put_codecb_node; + } =20 comp_idx =3D 0; priv->dai_links[*link_idx].cpus =3D &compnent[comp_idx++]; @@ -816,6 +829,15 @@ static int j721e_soc_probe_ivi(struct j721e_priv *priv= , int *link_idx, (*conf_idx)++; =20 return 0; + + +put_codecb_node: + of_node_put(codecb_node); +put_codeca_node: + of_node_put(codeca_node); +put_dai_node: + of_node_put(dai_node); + return ret; } =20 static int j721e_soc_probe(struct platform_device *pdev) --=20 2.25.1