[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABXOdTcDfy3oDVy6+FAg+jkqnCJABOq=VokWQ1q4QByKbo5UJQ@mail.gmail.com>
Date: Mon, 10 Apr 2023 20:02:54 -0700
From: Guenter Roeck <groeck@...gle.com>
To: Aashish Sharma <shraash@...gle.com>
Cc: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
Trevor Wu <trevor.wu@...iatek.com>,
Guenter Roeck <groeck@...omium.org>,
alsa-devel@...a-project.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org,
kernel test robot <lkp@...el.com>,
Julia Lawall <julia.lawall@...ia.fr>
Subject: Re: [PATCH] ASoC: mediatek: common: Fix refcount leak in parse_dai_link_info
On Mon, Apr 10, 2023 at 5:34 PM Aashish Sharma <shraash@...gle.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@...el.com>
> Reported-by: Julia Lawall <julia.lawall@...ia.fr>
> Link: https://lore.kernel.org/r/202304090504.2K8L6soj-lkp@intel.com/
> Signed-off-by: Aashish Sharma <shraash@...gle.com>
Reviewed-by: Guenter Roeck <groeck@...omium.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
>
Powered by blists - more mailing lists