Skip to contentSkip to conversation

media: cobalt: Avoid freeing ALSA private data twice

PATCH New Ruoyu Wang 1 participant 1 message Jul 8

Subsystems (2)
lore
Share & tools
lore

Ruoyu Wang

author
#0 lore raw

PATCH 1/1 media: cobalt: Avoid freeing ALSA private data twice

snd_cobalt_card_create() stores cobsc in sc->private_data and installs snd_cobalt_card_private_free() as sc->private_free. From that point, snd_card_free(sc) releases cobsc through the ALSA card cleanup path.

If cobalt_alsa_init() fails after snd_cobalt_card_create(), the err_exit_free path calls snd_card_free(sc) and then kfree(cobsc). That second free releases the same object again.

Remove the explicit kfree(cobsc) and leave ownership with the ALSA card.

This issue was found by a static analysis checker and confirmed by manual source review.

Fixes 85756a069c55 ("[media] cobalt: add new driver")
---
 drivers/media/pci/cobalt/cobalt-alsa-main.c | 1 -
 1 file changed, 1 deletion(-)
drivers/media/pci/cobalt/cobalt-alsa-main.c +0 -1
index 7bb7f13c70c0d..9ed547cd40af5 100644
@@ -135,7 +135,6 @@ int cobalt_alsa_init(struct cobalt_stream *s)
 err_exit_free:
 	if (sc != NULL)
 		snd_card_free(sc);
-	kfree(cobsc);
 err_exit:
 	return ret;
 }
Signature · 1 line
2.51.0