2020-07-16 13:25:07

by Jing Xiangfeng

[permalink] [raw]
Subject: [PATCH] ASoC: meson: add the missed kfree() for axg_card_add_tdm_loopback

axg_card_add_tdm_loopback() misses to call kfree() in an error path. Add
the missed function call to fix it.

Fixes: c84836d7f650 ("ASoC: meson: axg-card: use modern dai_link style")
Signed-off-by: Jing Xiangfeng <[email protected]>
---
sound/soc/meson/axg-card.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c
index 89f7f64747cd..6eac22ba8b99 100644
--- a/sound/soc/meson/axg-card.c
+++ b/sound/soc/meson/axg-card.c
@@ -121,8 +121,10 @@ static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
return -ENOMEM;

dlc = devm_kzalloc(card->dev, 2 * sizeof(*dlc), GFP_KERNEL);
- if (!dlc)
+ if (!dlc) {
+ kfree(lb->name);
return -ENOMEM;
+ }

lb->cpus = &dlc[0];
lb->codecs = &dlc[1];
--
2.17.1


2020-07-16 13:32:32

by Jerome Brunet

[permalink] [raw]
Subject: Re: [PATCH] ASoC: meson: add the missed kfree() for axg_card_add_tdm_loopback


On Thu 16 Jul 2020 at 15:25, Jing Xiangfeng <[email protected]> wrote:

> axg_card_add_tdm_loopback() misses to call kfree() in an error path. Add
> the missed function call to fix it.
>
> Fixes: c84836d7f650 ("ASoC: meson: axg-card: use modern dai_link style")
> Signed-off-by: Jing Xiangfeng <[email protected]>

Thanks for fixing this.
Maybe it would be better to use the devm_ variant for the name instead ?

> ---
> sound/soc/meson/axg-card.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c
> index 89f7f64747cd..6eac22ba8b99 100644
> --- a/sound/soc/meson/axg-card.c
> +++ b/sound/soc/meson/axg-card.c
> @@ -121,8 +121,10 @@ static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
> return -ENOMEM;
>
> dlc = devm_kzalloc(card->dev, 2 * sizeof(*dlc), GFP_KERNEL);
> - if (!dlc)
> + if (!dlc) {
> + kfree(lb->name);
> return -ENOMEM;
> + }
>
> lb->cpus = &dlc[0];
> lb->codecs = &dlc[1];

2020-07-16 14:38:00

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] ASoC: meson: add the missed kfree() for axg_card_add_tdm_loopback

On Thu, Jul 16, 2020 at 03:29:39PM +0200, Jerome Brunet wrote:
> On Thu 16 Jul 2020 at 15:25, Jing Xiangfeng <[email protected]> wrote:

> > axg_card_add_tdm_loopback() misses to call kfree() in an error path. Add
> > the missed function call to fix it.
> >
> > Fixes: c84836d7f650 ("ASoC: meson: axg-card: use modern dai_link style")
> > Signed-off-by: Jing Xiangfeng <[email protected]>

> Thanks for fixing this.
> Maybe it would be better to use the devm_ variant for the name instead ?

Yes, that should be more robust.


Attachments:
(No filename) (552.00 B)
signature.asc (499.00 B)
Download all attachments

2020-07-17 01:49:56

by Jing Xiangfeng

[permalink] [raw]
Subject: Re: [PATCH] ASoC: meson: add the missed kfree() for axg_card_add_tdm_loopback



On 2020/7/16 21:29, Jerome Brunet wrote:
>
> On Thu 16 Jul 2020 at 15:25, Jing Xiangfeng <[email protected]> wrote:
>
>> axg_card_add_tdm_loopback() misses to call kfree() in an error path. Add
>> the missed function call to fix it.
>>
>> Fixes: c84836d7f650 ("ASoC: meson: axg-card: use modern dai_link style")
>> Signed-off-by: Jing Xiangfeng <[email protected]>
>
> Thanks for fixing this.
> Maybe it would be better to use the devm_ variant for the name instead ?

Ok, I'll send a v2 with this change.

Thanks for your review.
>
>> ---
>> sound/soc/meson/axg-card.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c
>> index 89f7f64747cd..6eac22ba8b99 100644
>> --- a/sound/soc/meson/axg-card.c
>> +++ b/sound/soc/meson/axg-card.c
>> @@ -121,8 +121,10 @@ static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
>> return -ENOMEM;
>>
>> dlc = devm_kzalloc(card->dev, 2 * sizeof(*dlc), GFP_KERNEL);
>> - if (!dlc)
>> + if (!dlc) {
>> + kfree(lb->name);
>> return -ENOMEM;
>> + }
>>
>> lb->cpus = &dlc[0];
>> lb->codecs = &dlc[1];
>
> .
>