Message ID | 20230411003431.4048700-1-shraash@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2247198vqo; Mon, 10 Apr 2023 17:48:43 -0700 (PDT) X-Google-Smtp-Source: AKy350agH6dh/QdrAjVEIRHFX6hr9DXhpz0NlaCXNjq+OjdUtSNPYaRPmYb38vton/ilIdA7XtzW X-Received: by 2002:a62:1a8e:0:b0:625:ea57:389b with SMTP id a136-20020a621a8e000000b00625ea57389bmr13121727pfa.5.1681174122808; Mon, 10 Apr 2023 17:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681174122; cv=none; d=google.com; s=arc-20160816; b=Yf9ueESbL2GJs0V1QXAdV6mNimKxsdORONVGHkrstpdqNnQix9II0mBEE2rH7HWpYx DtgArQUYWbYp/uokUFPp3qVuIv8GbXqqZHb8p5LSdv18tUUvhpQIvATXsbRMYqHpLQuk +vCFQ4A2N1gSHwQsmJ0SNrSEgb9lxJ97C7zf7ARgF0Yg+bVI0sB53G+te9GbvRQmTBX3 itOmqh/DW17E8OUVy1jdHzycfArZFllqVsU4SXhKG7OGxthpv68DMipy44tB2RxjFtWn fbBAbrugJGPWfFXjsTXXHxTQAz3QFm7GFyzPF42KW52k7jqFXo/c40QipNRjFuZQZeWd kMpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=VV8PXIioY+lpB4ukX6X0D5BOfhtAOO5OAgem+yfBPzU=; b=p48uYTxKdPJ/PDQjgJD4arlie0asPe9UgajiDo6IsjMKv1h55l4/4HjPYJ/qlec9Wi cs7kfueQDKmoqsrrTrvgpcZW/Qs+f991uUa6fRg1KS3sJLGgyk54iIKvhikxMluGSkjD 3/kqU+O4+EChCwWGL+qrPPOAXGUjMVOtRi9tCtB4GhvT6ugzAXFAgGukdvlnvFZPVBpo qOh0xAulWvsJ3W/VZCetfPKwNVmKlkvr/xLILDQxQL2DPf+lRA416VaVcT9HOaZQ0MP6 vcql8kKalmjQ/PNXh5pDNmAYrZ3lezHQZ9/DJn+yVtFrl39XlCajlbh9S40vW76s4AMr N0DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MmK3pxBN; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z25-20020aa79599000000b00624c3ad6c03si11991141pfj.227.2023.04.10.17.48.30; Mon, 10 Apr 2023 17:48:42 -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; dkim=pass header.i=@google.com header.s=20210112 header.b=MmK3pxBN; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229814AbjDKAes (ORCPT <rfc822;yuanzuo1009@gmail.com> + 99 others); Mon, 10 Apr 2023 20:34:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbjDKAeq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 10 Apr 2023 20:34:46 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D75A13A for <linux-kernel@vger.kernel.org>; Mon, 10 Apr 2023 17:34:45 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 184-20020a2515c1000000b009419f64f6afso7257710ybv.2 for <linux-kernel@vger.kernel.org>; Mon, 10 Apr 2023 17:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1681173284; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=VV8PXIioY+lpB4ukX6X0D5BOfhtAOO5OAgem+yfBPzU=; b=MmK3pxBNM65yrkcmg8H132ZjPXqBIfU8z53aiLZbcxVHdcwb5CxL8/4Ji3dTd45Ip+ LH4bIxVQsf56Vf+CzVcoUVCFcU/eEyCgoDSaYc+HqLLM7hM8dqa102ICTIcGv7qsMHi1 J/xwCIAjHtxOMJaInNbFK8BeHNh/qjqh7EY4zQ2YwOTKUbt29zBQmAN3AqYH6uuXGbEH UiXkilwXN53YlQxZZVx2k9i8YWOSaYRcLTkImGjjcDnk3DzPFom7ZZKbhapeq4ayIQfp n04N3l/3G+PsiwKyKl3fdGBEo5ieR6beOSTFl9D01wkPtnHUs3jQlqmZY/Nr/kfSC7YE pabg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681173284; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=VV8PXIioY+lpB4ukX6X0D5BOfhtAOO5OAgem+yfBPzU=; b=AqG9JhEKWJwIGiNMWjRuNiM8+KnYLp2albgbrAfy12mR92bejmIYVX9pWfWN0iTnmf fDKH6RQdBxuPK/hAje+cxwmxYEXiCRwhTkVNaA/p92ycHhNEXECE0U2yprmyCxYt6Sta 5jSMcCaryqOZzp6oIx2jGrsj0GCaMGNsoqk60adp5rsgaNx8KdrymI4joRqbMz1bWYPE eCbbHTQRtNjSWolLurpk7j4aWkg443XQ+H7zCPX6QVFWELabhRUasDshW5mG5Y0UH/xw nAEzmaC1xsO7NwDzaxQ9s+qEMBle9wkx7THgduEB9qh0vndO0hfBUQwxBVfT2fFr2QZ+ judg== X-Gm-Message-State: AAQBX9cqrpqw4RR3lH13onohjC7lDwPSnNucQIqNTg+pWV3QZgMJljdk iUZsHUy8LG6L7mJR5YPXTR+bICCSHj+r X-Received: from ezekiel.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:108e]) (user=shraash job=sendgmr) by 2002:a81:b284:0:b0:544:94fe:4244 with SMTP id q126-20020a81b284000000b0054494fe4244mr636814ywh.10.1681173284695; Mon, 10 Apr 2023 17:34:44 -0700 (PDT) Date: Tue, 11 Apr 2023 06:04:31 +0530 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230411003431.4048700-1-shraash@google.com> Subject: [PATCH] ASoC: mediatek: common: Fix refcount leak in parse_dai_link_info From: Aashish Sharma <shraash@google.com> To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Trevor Wu <trevor.wu@mediatek.com>, Guenter Roeck <groeck@chromium.org> Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Aashish Sharma <shraash@google.com>, kernel test robot <lkp@intel.com>, Julia Lawall <julia.lawall@inria.fr> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762838836925406683?= X-GMAIL-MSGID: =?utf-8?q?1762838836925406683?= |
Series |
ASoC: mediatek: common: Fix refcount leak in parse_dai_link_info
|
|
Commit Message
Aashish Sharma
April 11, 2023, 12:34 a.m. UTC
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 <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@inria.fr>
Link: https://lore.kernel.org/r/202304090504.2K8L6soj-lkp@intel.com/
Signed-off-by: Aashish Sharma <shraash@google.com>
---
sound/soc/mediatek/common/mtk-soundcard-driver.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
Comments
On Mon, Apr 10, 2023 at 5:34 PM Aashish Sharma <shraash@google.com> wrote: > > 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 <lkp@intel.com> > Reported-by: Julia Lawall <julia.lawall@inria.fr> > Link: https://lore.kernel.org/r/202304090504.2K8L6soj-lkp@intel.com/ > Signed-off-by: Aashish Sharma <shraash@google.com> Reviewed-by: Guenter Roeck <groeck@chromium.org> > --- > 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; > -- > 2.40.0.577.gac1e443424-goog >
On Tue, 2023-04-11 at 06:04 +0530, Aashish Sharma wrote: > External email : Please do not click links or open attachments until > you have verified the sender or the content. > > > 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 <lkp@intel.com> > Reported-by: Julia Lawall <julia.lawall@inria.fr> > Link: https://lore.kernel.org/r/202304090504.2K8L6soj-lkp@intel.com/ > Signed-off-by: Aashish Sharma <shraash@google.com> Reviewed-by: Trevor Wu <trevor.wu@mediatek.com> > --- > 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; > -- > 2.40.0.577.gac1e443424-goog >
On Tue, 11 Apr 2023 06:04:31 +0530, Aashish Sharma wrote: > 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. > > Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next Thanks! [1/1] ASoC: mediatek: common: Fix refcount leak in parse_dai_link_info commit: beed115c2ce78f990222a29abed042582df4e87c All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
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;