[PATCH 2/3] media: cx18: Fix potential double free on ALSA initialization failure

From: Guangshuo Li

Date: Fri Oct 30 2026 - 12:56:06 EST


After snd_cx18_card_create() succeeds, the card's private_free callback
owns cxsc. snd_card_free() already invokes that callback on subsequent
initialization failures, so the explicit kfree() frees cxsc twice.

Remove the redundant free.

This issue was found by our static analysis tool under development.

Fixes: 2c87d9db46d1 ("[media] drivers/media/video: fix memory leak of snd_cx18_init()")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: OpenAI:gpt-6-astra
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
Build-tested the changed object with x86_64 allmodconfig.
No runtime or fault-injection testing was performed.

drivers/media/pci/cx18/cx18-alsa-main.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/media/pci/cx18/cx18-alsa-main.c b/drivers/media/pci/cx18/cx18-alsa-main.c
index b77f5375f3ff..7fe538621d4e 100644
--- a/drivers/media/pci/cx18/cx18-alsa-main.c
+++ b/drivers/media/pci/cx18/cx18-alsa-main.c
@@ -171,7 +171,6 @@ static int snd_cx18_init(struct v4l2_device *v4l2_dev)
err_exit_free:
if (sc != NULL)
snd_card_free(sc);
- kfree(cxsc);
err_exit:
return ret;
}