[PATCH] media: ti: vip: Fix potential use-after-free after stream setup failure

From: Guangshuo Li

Date: Mon Nov 16 2026 - 09:22:17 EST


alloc_stream() publishes the stream in cap_streams before completing
initialization. Its failure path frees the stream without clearing that
slot, so port teardown can pass a freed stream to free_stream().

Clear the slot when rolling back stream allocation.

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

Fixes: fc2873aa4a21 ("media: ti: vpe: Add the VIP driver")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/media/platform/ti/vpe/vip.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/ti/vpe/vip.c b/drivers/media/platform/ti/vpe/vip.c
index 2bbe8eb31555..6cdbd9946da3 100644
--- a/drivers/media/platform/ti/vpe/vip.c
+++ b/drivers/media/platform/ti/vpe/vip.c
@@ -3149,6 +3149,7 @@ static int alloc_stream(struct vip_port *port, int stream_id, int vfl_type)
do_free_hwlist:
vpdma_hwlist_release(dev->shared->vpdma, stream->list_num);
do_free_stream:
+ port->cap_streams[stream_id] = NULL;
kfree(stream);
return ret;
}

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4