media: qcom: iris: Add sanity check for stop streaming
Subsystems (4)
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
@@ -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
Quoted 29 lines · Wangao Wang
Add sanity check in
iris_vb2_stop_streaming. Ifinst->stateis alreadyIRIS_INST_ERROR, we should skip thestream_offoperation because it would still send packets to the firmware.In
iris_vdec_kill_session,inst->stateis set toIRIS_INST_ERRORandsession_closeis executed, which willkfree(inst_hfi_gen2->packet). Ifstop_streamingis called afterward, it will cause a crash.Signed-off-by Wangao Wang <[email protected]>--- 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@@ -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
-0if (ret)iris_inst_change_state (inst,IRIS_INST_ERROR );
Signature · 2 lines
Best Regards, Renjiang
Dikshita Agarwal
maintainerQuoted 18 lines · Wangao Wang
Add sanity check in
iris_vb2_stop_streaming. Ifinst->stateis alreadyIRIS_INST_ERROR, we should skip thestream_offoperation because it would still send packets to the firmware.In
iris_vdec_kill_session,inst->stateis set toIRIS_INST_ERRORandsession_closeis executed, which willkfree(inst_hfi_gen2->packet). Ifstop_streamingis called afterward, it will cause a crash.Signed-off-by Wangao Wang <[email protected]>--- 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
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 );