* [PATCH v1] media: qcom: iris: Add sanity check for stop streaming
@ 2025-10-16 7:25 Wangao Wang
2025-10-16 8:59 ` Renjiang Han
2025-10-16 11:06 ` Dikshita Agarwal
0 siblings, 2 replies; 3+ messages in thread
From: Wangao Wang @ 2025-10-16 7:25 UTC (permalink / raw)
To: vikash.garodia, dikshita.agarwal, abhinav.kumar, bod, mchehab
Cc: linux-media, linux-arm-msm, linux-kernel, quic_qiweil,
quic_renjiang, 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.
Signed-off-by: Wangao Wang <wangao.wang@oss.qualcomm.com>
---
drivers/media/platform/qcom/iris/iris_vb2.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/platform/qcom/iris/iris_vb2.c
index 139b821f7952..c1647fb4f0cc 100644
--- a/drivers/media/platform/qcom/iris/iris_vb2.c
+++ b/drivers/media/platform/qcom/iris/iris_vb2.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] media: qcom: iris: Add sanity check for stop streaming
2025-10-16 7:25 [PATCH v1] media: qcom: iris: Add sanity check for stop streaming Wangao Wang
@ 2025-10-16 8:59 ` Renjiang Han
2025-10-16 11:06 ` Dikshita Agarwal
1 sibling, 0 replies; 3+ messages in thread
From: Renjiang Han @ 2025-10-16 8:59 UTC (permalink / raw)
To: Wangao Wang, vikash.garodia, dikshita.agarwal, abhinav.kumar, bod,
mchehab
Cc: linux-media, linux-arm-msm, linux-kernel, quic_qiweil
On 10/16/2025 3:25 PM, Wangao Wang wrote:
> 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.
>
> Signed-off-by: Wangao Wang <wangao.wang@oss.qualcomm.com>
> ---
> drivers/media/platform/qcom/iris/iris_vb2.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/platform/qcom/iris/iris_vb2.c
> index 139b821f7952..c1647fb4f0cc 100644
> --- a/drivers/media/platform/qcom/iris/iris_vb2.c
> +++ b/drivers/media/platform/qcom/iris/iris_vb2.c
> @@ -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);
It is necessary to distinguish between error and normal states.
> if (ret)
> iris_inst_change_state(inst, IRIS_INST_ERROR);
--
Best Regards,
Renjiang
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] media: qcom: iris: Add sanity check for stop streaming
2025-10-16 7:25 [PATCH v1] media: qcom: iris: Add sanity check for stop streaming Wangao Wang
2025-10-16 8:59 ` Renjiang Han
@ 2025-10-16 11:06 ` Dikshita Agarwal
1 sibling, 0 replies; 3+ messages in thread
From: Dikshita Agarwal @ 2025-10-16 11:06 UTC (permalink / raw)
To: Wangao Wang, vikash.garodia, abhinav.kumar, bod, mchehab
Cc: linux-media, linux-arm-msm, linux-kernel, quic_qiweil,
quic_renjiang
On 10/16/2025 12:55 PM, Wangao Wang wrote:
> 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.
>
> Signed-off-by: Wangao Wang <wangao.wang@oss.qualcomm.com>
> ---
> drivers/media/platform/qcom/iris/iris_vb2.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/platform/qcom/iris/iris_vb2.c
> index 139b821f7952..c1647fb4f0cc 100644
> --- a/drivers/media/platform/qcom/iris/iris_vb2.c
> +++ b/drivers/media/platform/qcom/iris/iris_vb2.c
> @@ -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
> + 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);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-16 11:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 7:25 [PATCH v1] media: qcom: iris: Add sanity check for stop streaming Wangao Wang
2025-10-16 8:59 ` Renjiang Han
2025-10-16 11:06 ` Dikshita Agarwal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox