Linux-Amlogic Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ASoC: meson: add the missed kfree() for axg_card_add_tdm_loopback
@ 2020-07-16 13:25 Jing Xiangfeng
  2020-07-16 13:29 ` Jerome Brunet
  0 siblings, 1 reply; 4+ messages in thread
From: Jing Xiangfeng @ 2020-07-16 13:25 UTC (permalink / raw)
  To: jbrunet, lgirdwood, broonie, perex, tiwai, khilman, kuninori.morimoto.gx
  Cc: linux-amlogic, alsa-devel, linux-kernel, linux-arm-kernel, jingxiangfeng

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 <jingxiangfeng@huawei.com>
---
 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


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: meson: add the missed kfree() for axg_card_add_tdm_loopback
  2020-07-16 13:25 [PATCH] ASoC: meson: add the missed kfree() for axg_card_add_tdm_loopback Jing Xiangfeng
@ 2020-07-16 13:29 ` Jerome Brunet
  2020-07-16 14:34   ` Mark Brown
  2020-07-17  1:49   ` Jing Xiangfeng
  0 siblings, 2 replies; 4+ messages in thread
From: Jerome Brunet @ 2020-07-16 13:29 UTC (permalink / raw)
  To: Jing Xiangfeng, lgirdwood, broonie, perex, tiwai, khilman,
	kuninori.morimoto.gx
  Cc: linux-amlogic, alsa-devel, linux-kernel, linux-arm-kernel


On Thu 16 Jul 2020 at 15:25, Jing Xiangfeng <jingxiangfeng@huawei.com> 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 <jingxiangfeng@huawei.com>

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];


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: meson: add the missed kfree() for axg_card_add_tdm_loopback
  2020-07-16 13:29 ` Jerome Brunet
@ 2020-07-16 14:34   ` Mark Brown
  2020-07-17  1:49   ` Jing Xiangfeng
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2020-07-16 14:34 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: alsa-devel, linux-kernel, kuninori.morimoto.gx, lgirdwood,
	khilman, tiwai, perex, linux-amlogic, Jing Xiangfeng,
	linux-arm-kernel

[-- Attachment #1.1: Type: text/plain, Size: 539 bytes --]

On Thu, Jul 16, 2020 at 03:29:39PM +0200, Jerome Brunet wrote:
> On Thu 16 Jul 2020 at 15:25, Jing Xiangfeng <jingxiangfeng@huawei.com> 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 <jingxiangfeng@huawei.com>

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

Yes, that should be more robust.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: meson: add the missed kfree() for axg_card_add_tdm_loopback
  2020-07-16 13:29 ` Jerome Brunet
  2020-07-16 14:34   ` Mark Brown
@ 2020-07-17  1:49   ` Jing Xiangfeng
  1 sibling, 0 replies; 4+ messages in thread
From: Jing Xiangfeng @ 2020-07-17  1:49 UTC (permalink / raw)
  To: Jerome Brunet, lgirdwood, broonie, perex, tiwai, khilman,
	kuninori.morimoto.gx
  Cc: linux-amlogic, alsa-devel, linux-kernel, linux-arm-kernel



On 2020/7/16 21:29, Jerome Brunet wrote:
>
> On Thu 16 Jul 2020 at 15:25, Jing Xiangfeng <jingxiangfeng@huawei.com> 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 <jingxiangfeng@huawei.com>
>
> 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];
>
> .
>

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-16 13:25 [PATCH] ASoC: meson: add the missed kfree() for axg_card_add_tdm_loopback Jing Xiangfeng
2020-07-16 13:29 ` Jerome Brunet
2020-07-16 14:34   ` Mark Brown
2020-07-17  1:49   ` Jing Xiangfeng

Linux-Amlogic Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-amlogic/0 linux-amlogic/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-amlogic linux-amlogic/ https://lore.kernel.org/linux-amlogic \
		linux-amlogic@lists.infradead.org
	public-inbox-index linux-amlogic

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-amlogic


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git