Skip to contentSkip to conversation

media: qcom: iris: Add sanity check for stop streaming

PATCH Superseded Wangao Wang 3 participants 3 messages Oct 16, 2025

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: qcom: iris: Add sanity check for stop streaming

Add sanity check in iris_vb2_stop_streaming. If inst->state is already IRIS_INST_ERROR, we should skip the stream_off operation because it would still send packets to the firmware.

In iris_vdec_kill_session, inst->state is set to IRIS_INST_ERROR and session_close is executed, which will kfree(inst_hfi_gen2->packet). If stop_streaming is called afterward, it will cause a crash.

---
 drivers/media/platform/qcom/iris/iris_vb2.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_vb2.c +7 -3
index 139b821f7952..c1647fb4f0cc 100644
@@ -231,16 +231,20 @@ void iris_vb2_stop_streaming(struct vb2_queue *q)
 		return;
 
 	mutex_lock(&inst->lock);
+	if (inst->state == IRIS_INST_ERROR) {
+		ret = -EBUSY;
+		goto error;
+	}
 
 	if (!V4L2_TYPE_IS_OUTPUT(q->type) &&
 	    !V4L2_TYPE_IS_CAPTURE(q->type))
-		goto exit;
+		goto error;
 
 	ret = iris_session_streamoff(inst, q->type);
 	if (ret)
-		goto exit;
+		goto error;
 
-exit:
+error:
 	iris_helper_buffers_done(inst, q->type, VB2_BUF_STATE_ERROR);
 	if (ret)
 		iris_inst_change_state(inst, IRIS_INST_ERROR);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 29 lines · Wangao Wang

Add sanity check in iris_vb2_stop_streaming. If inst->state is already IRIS_INST_ERROR, we should skip the stream_off operation because it would still send packets to the firmware.

In iris_vdec_kill_session, inst->state is set to IRIS_INST_ERROR and session_close is executed, which will kfree(inst_hfi_gen2->packet). If stop_streaming is called afterward, it will cause a crash.

---
  drivers/media/platform/qcom/iris/iris_vb2.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_vb2.c +4 -1
index 139b821f7952..c1647fb4f0cc 100644
@@ -231,16 +231,20 @@ void iris_vb2_stop_streaming(struct vb2_queue *q)
  		return;
 
  	mutex_lock(&inst->lock);
+	if (inst->state == IRIS_INST_ERROR) {
+		ret = -EBUSY;
+		goto error;
+	}
 
  	if (!V4L2_TYPE_IS_OUTPUT(q->type) &&
  	    !V4L2_TYPE_IS_CAPTURE(q->type))
-		goto exit;

drivers/media/platform/qcom/iris/iris_vb2.c void iris_vb2_stop_streaming(struct vb2_queue *q) · line 248

Quoted 10 lines
drivers/media/platform/qcom/iris/iris_vb2.c +3 -2
+		goto error;
 
  	ret = iris_session_streamoff(inst, q->type);
  	if (ret)
-		goto exit;
+		goto error;
 
-exit:
+error:
  	iris_helper_buffers_done(inst, q->type, VB2_BUF_STATE_ERROR);

It is necessary to distinguish between error and normal states.

Quoted 2 lines
drivers/media/platform/qcom/iris/iris_vb2.c +0 -0
  	if (ret)
  		iris_inst_change_state(inst, IRIS_INST_ERROR);
Signature · 2 lines
Best Regards,
Renjiang
maintainer
#2 lore raw
In reply to Wangao Wang
Quoted 18 lines · Wangao Wang

Add sanity check in iris_vb2_stop_streaming. If inst->state is already IRIS_INST_ERROR, we should skip the stream_off operation because it would still send packets to the firmware.

In iris_vdec_kill_session, inst->state is set to IRIS_INST_ERROR and session_close is executed, which will kfree(inst_hfi_gen2->packet). If stop_streaming is called afterward, it will cause a crash.

---
 drivers/media/platform/qcom/iris/iris_vb2.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_vb2.c +0 -0
index 139b821f7952..c1647fb4f0cc 100644

drivers/media/platform/qcom/iris/iris_vb2.c void iris_vb2_stop_streaming(struct vb2_queue *q) · line 235

Quoted 5 lines
drivers/media/platform/qcom/iris/iris_vb2.c +2 -0
@@ -231,16 +231,20 @@ void iris_vb2_stop_streaming(struct vb2_queue *q)
 		return;
 
 	mutex_lock(&inst->lock);
+	if (inst->state == IRIS_INST_ERROR) {
+		ret = -EBUSY;

ret is only used to trigger a state change to ERROR in this void API. Since the instance is already in ERROR state, assigning ret = -EBUSY is redundant and has no functional impact.

Thanks,
Dikshita

Quoted 18 lines
drivers/media/platform/qcom/iris/iris_vb2.c +5 -3
+		goto error;
+	}
 
 	if (!V4L2_TYPE_IS_OUTPUT(q->type) &&
 	    !V4L2_TYPE_IS_CAPTURE(q->type))
-		goto exit;
+		goto error;
 
 	ret = iris_session_streamoff(inst, q->type);
 	if (ret)
-		goto exit;
+		goto error;
 
-exit:
+error:
 	iris_helper_buffers_done(inst, q->type, VB2_BUF_STATE_ERROR);
 	if (ret)
 		iris_inst_change_state(inst, IRIS_INST_ERROR);