[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <205df0d4-e04a-9871-1250-fdd04096ac38@oss.qualcomm.com>
Date: Wed, 7 Jan 2026 15:36:22 +0530
From: Dikshita Agarwal <dikshita.agarwal@....qualcomm.com>
To: Bryan O'Donoghue <bod@...nel.org>,
Vikash Garodia <vikash.garodia@....qualcomm.com>,
Abhinav Kumar <abhinav.kumar@...ux.dev>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Hans Verkuil <hverkuil@...nel.org>,
Stefan Schmidt <stefan.schmidt@...aro.org>,
Hans Verkuil <hverkuil+cisco@...nel.org>,
Wangao Wang <wangao.wang@....qualcomm.com>
Cc: linux-media@...r.kernel.org, linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org,
Bryan O'Donoghue <bryan.odonoghue@...aro.org>
Subject: Re: [PATCH v2 5/6] media: iris: gen2: Add sanity check for session
stop
On 12/30/2025 4:03 PM, Bryan O'Donoghue wrote:
> On 29/12/2025 06:31, Dikshita Agarwal wrote:
>> In iris_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.
>>
>> Add a NULL check for inst_hfi_gen2->packet before sendling STOP packet
>> to firmware to fix that.
>>
>> Fixes: 11712ce70f8e ("media: iris: implement vb2 streaming ops")
>> Signed-off-by: Dikshita Agarwal <dikshita.agarwal@....qualcomm.com>
>> ---
>> drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
>> b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
>> index
>> 6a772db2ec33fb002d8884753a41dc98b3a8439d..59e41adcce9aadd7c60bb1d369d68a4954f62aef 100644
>> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
>> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
>> @@ -963,6 +963,9 @@ static int iris_hfi_gen2_session_stop(struct
>> iris_inst *inst, u32 plane)
>> struct iris_inst_hfi_gen2 *inst_hfi_gen2 =
>> to_iris_inst_hfi_gen2(inst);
>> int ret = 0;
>>
>> + if (!inst_hfi_gen2->packet)
>> + return -EINVAL;
>> +
>> reinit_completion(&inst->completion);
>>
>> iris_hfi_gen2_packet_session_command(inst,
>>
>> --
>> 2.34.1
>>
>
> Are you sure this NULL check is concurrency safe ?
>
> i.e. that ->session_stop() and ->session_close() cannot be executed
> concurrently ?
Yes, this is concurrency safe.
Both iris_hfi_gen2_session_stop() and iris_kill_session() are invoked while
holding inst->lock. For instance, iris_vb2_stop_streaming() locks the mutex
before calling session_stop(), and iris_kill_session() / session_close()
also grab the same lock before freeing inst_hfi_gen2->packet.
That ensures they never run concurrently, so the NULL-check protects
against the packet having been freed earlier without racing.
Thanks,
Dikshita
>
> ---
> bod
Powered by blists - more mailing lists