Skip to content

Commit 2a03b40

Browse files
ISCAS-Vulabtiwai
authored andcommitted
ALSA: vxpocket: Fix resource leak in vxpocket_probe error path
When vxpocket_config() fails, vxpocket_probe() returns the error code directly without freeing the sound card resources allocated by snd_card_new(), which leads to a memory leak. Add proper error handling to free the sound card and clear the allocation bit when vxpocket_config() fails. Fixes: 15b99ac ("[PATCH] pcmcia: add return value to _config() functions") Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Link: https://patch.msgid.link/20251215042652.695-1-vulab@iscas.ac.cn Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent e64826e commit 2a03b40

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

sound/pcmcia/vx/vxpocket.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,13 @@ static int vxpocket_probe(struct pcmcia_device *p_dev)
284284

285285
vxp->p_dev = p_dev;
286286

287-
return vxpocket_config(p_dev);
287+
err = vxpocket_config(p_dev);
288+
if (err < 0) {
289+
card_alloc &= ~(1 << i);
290+
snd_card_free(card);
291+
return err;
292+
}
293+
return 0;
288294
}
289295

290296
static void vxpocket_detach(struct pcmcia_device *link)

0 commit comments

Comments
 (0)