Skip to contentSkip to conversation

ALSA: pci: Fix memory leak in snd_ali_create

PATCH In review Navid Emamdoost 2 participants 2 messages Oct 27, 2019 – Oct 28, 2019 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: pci: Fix memory leak in snd_ali_create

In the implementation of snd_ali_create() the memory allocated for codec is leaked in case of an error. Release codec if snd_ali_chip_init() fails.

Fixes f9ab2b1c3ab5 ("[ALSA] ali5451 - Code clean up, irq handler fix")
---
 sound/pci/ali5451/ali5451.c | 1 +
 1 file changed, 1 insertion(+)
sound/pci/ali5451/ali5451.c +1 -0
index 6e28e381c21a..3ed07a18be4d 100644
@@ -2179,6 +2179,7 @@ static int snd_ali_create(struct snd_card *card,
 	err = snd_ali_chip_init(codec);
 	if (err < 0) {
 		dev_err(card->dev, "ali create: chip init error.\n");
+		snd_ali_free(codec);
 		return err;
 	}
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · Navid Emamdoost

In the implementation of snd_ali_create() the memory allocated for codec is leaked in case of an error. Release codec if snd_ali_chip_init() fails.

Once again, this is a wrong fix. The code path is after snd_device_new() with the free op, so the object gets already released there.

thanks,

Takashi

Quoted 22 lines
Fixes f9ab2b1c3ab5 ("[ALSA] ali5451 - Code clean up, irq handler fix")
---
 sound/pci/ali5451/ali5451.c | 1 +
 1 file changed, 1 insertion(+)
sound/pci/ali5451/ali5451.c +1 -0
index 6e28e381c21a..3ed07a18be4d 100644
@@ -2179,6 +2179,7 @@ static int snd_ali_create(struct snd_card *card,
 	err = snd_ali_chip_init(codec);
 	if (err < 0) {
 		dev_err(card->dev, "ali create: chip init error.\n");
+		snd_ali_free(codec);
 		return err;
 	}
 
Signature · 1 line
2.17.1