[PATCH 1/2] media: solo6x10: Fix potential double free on encoder init failure
From: Tian Xuechen
Date: Sat Dec 05 2026 - 03:21:46 EST
Partial encoder initialization frees the successful encoders but leaves
their pointers in v4l2_enc. The outer probe unwind visits those entries
again, including the failed entry containing an error pointer.
Clear both the failed entry and each freed encoder slot.
This issue was found by our static analysis tool under development.
Fixes: faa4fd2a0951 ("Staging: solo6x10: New driver (staging) for Softlogic 6x10")
Signed-off-by: Tian Xuechen <202300460064@xxxxxxxxxxxxxxx>
---
drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
index 91b5c4161930..a4d7872ed869 100644
--- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
@@ -1357,8 +1357,11 @@ int solo_enc_v4l2_init(struct solo_dev *solo_dev, unsigned nr)
if (i != solo_dev->nr_chans) {
int ret = PTR_ERR(solo_dev->v4l2_enc[i]);
- while (i--)
+ solo_dev->v4l2_enc[i] = NULL;
+ while (i--) {
solo_enc_free(solo_dev->v4l2_enc[i]);
+ solo_dev->v4l2_enc[i] = NULL;
+ }
dma_free_coherent(&solo_dev->pdev->dev, solo_dev->vh_size,
solo_dev->vh_buf, solo_dev->vh_dma);
solo_dev->vh_buf = NULL;