From patchwork Tue Apr 11 00:34:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aashish Sharma X-Patchwork-Id: 13208495 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B1A7C77B6E for ; Wed, 12 Apr 2023 05:28:37 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0D9A0EC2; Wed, 12 Apr 2023 07:27:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0D9A0EC2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1681277315; bh=eKPMZ3eh1kwDuFELvQo8w68rSa6BbhN8qBrEaqJbYko=; h=Date:Subject:To:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From:Reply-To:Cc:From; b=C/K/JNE3rOWip4S7R6y/cuaqks6UNC4JI5fBaL9QH9OU6mUajodR4ytjwgElDb44x jzdwgj9hqu5YW0BscSdc0kywK1vcp0jXPiZEkSio6Xy5BHJzeFkcnB0b78r7WKWUyf OlVCfzQ2/CDsZCYu1UAzCogLA5lc1ATi52fRVC0c= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 49587F80549; Wed, 12 Apr 2023 07:26:16 +0200 (CEST) Date: Tue, 11 Apr 2023 06:04:31 +0530 Subject: [PATCH] ASoC: mediatek: common: Fix refcount leak in parse_dai_link_info To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Matthias Brugger , AngeloGioacchino Del Regno , Trevor Wu , Guenter Roeck X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 X-Mailman-Approved-At: Wed, 12 Apr 2023 05:22:43 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <168127717464.26.8163797399161129916@mailman-core.alsa-project.org> X-Patchwork-Original-From: Aashish Sharma via Alsa-devel From: Aashish Sharma Reply-To: Aashish Sharma Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Aashish Sharma , kernel test robot , Julia Lawall Content-Disposition: inline Add missing of_node_put()s before the returns to balance of_node_get()s and of_node_put()s, which may get unbalanced in case the for loop 'for_each_available_child_of_node' returns early. Fixes: 4302187d955f ("ASoC: mediatek: common: add soundcard driver common code") Reported-by: kernel test robot Reported-by: Julia Lawall Link: https://lore.kernel.org/r/202304090504.2K8L6soj-lkp@intel.com/ Signed-off-by: Aashish Sharma --- sound/soc/mediatek/common/mtk-soundcard-driver.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.c b/sound/soc/mediatek/common/mtk-soundcard-driver.c index 7c55c2cb1f21..738093451ccb 100644 --- a/sound/soc/mediatek/common/mtk-soundcard-driver.c +++ b/sound/soc/mediatek/common/mtk-soundcard-driver.c @@ -47,20 +47,26 @@ int parse_dai_link_info(struct snd_soc_card *card) /* Loop over all the dai link sub nodes */ for_each_available_child_of_node(dev->of_node, sub_node) { if (of_property_read_string(sub_node, "link-name", - &dai_link_name)) + &dai_link_name)) { + of_node_put(sub_node); return -EINVAL; + } for_each_card_prelinks(card, i, dai_link) { if (!strcmp(dai_link_name, dai_link->name)) break; } - if (i >= card->num_links) + if (i >= card->num_links) { + of_node_put(sub_node); return -EINVAL; + } ret = set_card_codec_info(card, sub_node, dai_link); - if (ret < 0) + if (ret < 0) { + of_node_put(sub_node); return ret; + } } return 0;