linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv3] media: venus: protect against spurious interrupts during probe
@ 2025-06-06 15:25 Jorge Ramirez-Ortiz
  2025-06-07  9:17 ` Bryan O'Donoghue
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jorge Ramirez-Ortiz @ 2025-06-06 15:25 UTC (permalink / raw)
  To: jorge.ramirez, quic_vgarodia, quic_dikshita, bryan.odonoghue,
	mchehab
  Cc: hans.verkuil, stanimir.varbanov, linux-media, linux-arm-msm,
	linux-kernel

Make sure the interrupt handler is initialized before the interrupt is
registered.

If the IRQ is registered before hfi_create(), it's possible that an
interrupt fires before the handler setup is complete, leading to a NULL
dereference.

This error condition has been observed during system boot on Rb3Gen2.

Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions")
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez@oss.qualcomm.com>
---
 v3:
    Added Fixes tag
 v2:
    Fix authorship
    Fix spelling mistake
 
 drivers/media/platform/qcom/venus/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index d305d74bb152..5bd99d0aafe4 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -424,13 +424,13 @@ static int venus_probe(struct platform_device *pdev)
 	INIT_DELAYED_WORK(&core->work, venus_sys_error_handler);
 	init_waitqueue_head(&core->sys_err_done);
 
-	ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, venus_isr_thread,
-					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
-					"venus", core);
+	ret = hfi_create(core, &venus_core_ops);
 	if (ret)
 		goto err_core_put;
 
-	ret = hfi_create(core, &venus_core_ops);
+	ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, venus_isr_thread,
+					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+					"venus", core);
 	if (ret)
 		goto err_core_put;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCHv3] media: venus: protect against spurious interrupts during probe
  2025-06-06 15:25 [PATCHv3] media: venus: protect against spurious interrupts during probe Jorge Ramirez-Ortiz
@ 2025-06-07  9:17 ` Bryan O'Donoghue
  2025-06-13 15:14 ` Bryan O'Donoghue
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Bryan O'Donoghue @ 2025-06-07  9:17 UTC (permalink / raw)
  To: Jorge Ramirez-Ortiz, quic_vgarodia, quic_dikshita, mchehab
  Cc: hans.verkuil, stanimir.varbanov, linux-media, linux-arm-msm,
	linux-kernel

On 06/06/2025 16:25, Jorge Ramirez-Ortiz wrote:
> Make sure the interrupt handler is initialized before the interrupt is
> registered.
> 
> If the IRQ is registered before hfi_create(), it's possible that an
> interrupt fires before the handler setup is complete, leading to a NULL
> dereference.
> 
> This error condition has been observed during system boot on Rb3Gen2.
> 
> Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions")
> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez@oss.qualcomm.com>
> ---
>   v3:
>      Added Fixes tag
>   v2:
>      Fix authorship
>      Fix spelling mistake
>   
>   drivers/media/platform/qcom/venus/core.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index d305d74bb152..5bd99d0aafe4 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -424,13 +424,13 @@ static int venus_probe(struct platform_device *pdev)
>   	INIT_DELAYED_WORK(&core->work, venus_sys_error_handler);
>   	init_waitqueue_head(&core->sys_err_done);
>   
> -	ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, venus_isr_thread,
> -					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> -					"venus", core);
> +	ret = hfi_create(core, &venus_core_ops);
>   	if (ret)
>   		goto err_core_put;
>   
> -	ret = hfi_create(core, &venus_core_ops);
> +	ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, venus_isr_thread,
> +					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> +					"venus", core);
>   	if (ret)
>   		goto err_core_put;
>   
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCHv3] media: venus: protect against spurious interrupts during probe
  2025-06-06 15:25 [PATCHv3] media: venus: protect against spurious interrupts during probe Jorge Ramirez-Ortiz
  2025-06-07  9:17 ` Bryan O'Donoghue
@ 2025-06-13 15:14 ` Bryan O'Donoghue
  2025-06-16 11:44 ` Vikash Garodia
  2025-06-19 18:14 ` Dikshita Agarwal
  3 siblings, 0 replies; 5+ messages in thread
From: Bryan O'Donoghue @ 2025-06-13 15:14 UTC (permalink / raw)
  To: Jorge Ramirez-Ortiz, quic_vgarodia, quic_dikshita, mchehab
  Cc: hans.verkuil, stanimir.varbanov, linux-media, linux-arm-msm,
	linux-kernel

On 06/06/2025 16:25, Jorge Ramirez-Ortiz wrote:
> Make sure the interrupt handler is initialized before the interrupt is
> registered.
> 
> If the IRQ is registered before hfi_create(), it's possible that an
> interrupt fires before the handler setup is complete, leading to a NULL
> dereference.
> 
> This error condition has been observed during system boot on Rb3Gen2.
> 
> Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions")
> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez@oss.qualcomm.com>
> ---
>   v3:
>      Added Fixes tag
>   v2:
>      Fix authorship
>      Fix spelling mistake
>   
>   drivers/media/platform/qcom/venus/core.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index d305d74bb152..5bd99d0aafe4 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -424,13 +424,13 @@ static int venus_probe(struct platform_device *pdev)
>   	INIT_DELAYED_WORK(&core->work, venus_sys_error_handler);
>   	init_waitqueue_head(&core->sys_err_done);
>   
> -	ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, venus_isr_thread,
> -					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> -					"venus", core);
> +	ret = hfi_create(core, &venus_core_ops);
>   	if (ret)
>   		goto err_core_put;
>   
> -	ret = hfi_create(core, &venus_core_ops);
> +	ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, venus_isr_thread,
> +					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> +					"venus", core);
>   	if (ret)
>   		goto err_core_put;
>   

@Dikshita @Vikash.

Good/happy with this patch ? Looks right to me.

---
bod

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCHv3] media: venus: protect against spurious interrupts during probe
  2025-06-06 15:25 [PATCHv3] media: venus: protect against spurious interrupts during probe Jorge Ramirez-Ortiz
  2025-06-07  9:17 ` Bryan O'Donoghue
  2025-06-13 15:14 ` Bryan O'Donoghue
@ 2025-06-16 11:44 ` Vikash Garodia
  2025-06-19 18:14 ` Dikshita Agarwal
  3 siblings, 0 replies; 5+ messages in thread
From: Vikash Garodia @ 2025-06-16 11:44 UTC (permalink / raw)
  To: Jorge Ramirez-Ortiz, quic_dikshita, bryan.odonoghue, mchehab
  Cc: hans.verkuil, stanimir.varbanov, linux-media, linux-arm-msm,
	linux-kernel


On 6/6/2025 8:55 PM, Jorge Ramirez-Ortiz wrote:
> Make sure the interrupt handler is initialized before the interrupt is
> registered.
> 
> If the IRQ is registered before hfi_create(), it's possible that an
> interrupt fires before the handler setup is complete, leading to a NULL
> dereference.
> 
> This error condition has been observed during system boot on Rb3Gen2.
> 
> Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions")
> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez@oss.qualcomm.com>
> ---
>  v3:
>     Added Fixes tag
>  v2:
>     Fix authorship
>     Fix spelling mistake
>  
>  drivers/media/platform/qcom/venus/core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index d305d74bb152..5bd99d0aafe4 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -424,13 +424,13 @@ static int venus_probe(struct platform_device *pdev)
>  	INIT_DELAYED_WORK(&core->work, venus_sys_error_handler);
>  	init_waitqueue_head(&core->sys_err_done);
>  
> -	ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, venus_isr_thread,
> -					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> -					"venus", core);
> +	ret = hfi_create(core, &venus_core_ops);
>  	if (ret)
>  		goto err_core_put;
>  
> -	ret = hfi_create(core, &venus_core_ops);
> +	ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, venus_isr_thread,
> +					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> +					"venus", core);
>  	if (ret)
>  		goto err_core_put;
>  
Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCHv3] media: venus: protect against spurious interrupts during probe
  2025-06-06 15:25 [PATCHv3] media: venus: protect against spurious interrupts during probe Jorge Ramirez-Ortiz
                   ` (2 preceding siblings ...)
  2025-06-16 11:44 ` Vikash Garodia
@ 2025-06-19 18:14 ` Dikshita Agarwal
  3 siblings, 0 replies; 5+ messages in thread
From: Dikshita Agarwal @ 2025-06-19 18:14 UTC (permalink / raw)
  To: Jorge Ramirez-Ortiz, quic_vgarodia, bryan.odonoghue, mchehab
  Cc: hans.verkuil, stanimir.varbanov, linux-media, linux-arm-msm,
	linux-kernel



On 6/6/2025 8:55 PM, Jorge Ramirez-Ortiz wrote:
> Make sure the interrupt handler is initialized before the interrupt is
> registered.
> 
> If the IRQ is registered before hfi_create(), it's possible that an
> interrupt fires before the handler setup is complete, leading to a NULL
> dereference.
> 
> This error condition has been observed during system boot on Rb3Gen2.
> 
> Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions")
> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez@oss.qualcomm.com>
> ---
>  v3:
>     Added Fixes tag
>  v2:
>     Fix authorship
>     Fix spelling mistake
>  
>  drivers/media/platform/qcom/venus/core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index d305d74bb152..5bd99d0aafe4 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -424,13 +424,13 @@ static int venus_probe(struct platform_device *pdev)
>  	INIT_DELAYED_WORK(&core->work, venus_sys_error_handler);
>  	init_waitqueue_head(&core->sys_err_done);
>  
> -	ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, venus_isr_thread,
> -					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> -					"venus", core);
> +	ret = hfi_create(core, &venus_core_ops);
>  	if (ret)
>  		goto err_core_put;
>  
> -	ret = hfi_create(core, &venus_core_ops);
> +	ret = devm_request_threaded_irq(dev, core->irq, hfi_isr, venus_isr_thread,
> +					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> +					"venus", core);
>  	if (ret)
>  		goto err_core_put;
>  
Reviewed-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Tested-by: Dikshita Agarwal <quic_dikshita@quicinc.com> # RB5

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-19 18:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-06 15:25 [PATCHv3] media: venus: protect against spurious interrupts during probe Jorge Ramirez-Ortiz
2025-06-07  9:17 ` Bryan O'Donoghue
2025-06-13 15:14 ` Bryan O'Donoghue
2025-06-16 11:44 ` Vikash Garodia
2025-06-19 18:14 ` Dikshita Agarwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).