The managed error IRQ is released after private state is freed on remove and post-request probe failures, allowing use-after-free in the handler. Free the IRQ before releasing private state on these paths. This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes: 9f2d0da9b8c3 ("media: cadence: csi2rx: Enable csi2rx_err_irq interrupt and add support for VIDIOC_LOG_STATUS") Assisted-by: LLM Cc: stable@vger.kernel.org Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak --- drivers/media/platform/cadence/cdns-csi2rx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index de7cce76397ab03b3dcdc4b5e68d2d92dca183ea..f8c626e19aa84569737aa785a31a0f8c94087613 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -993,7 +993,7 @@ static int csi2rx_probe(struct platform_device *pdev) ret = v4l2_subdev_init_finalize(&csi2rx->subdev); if (ret) - goto err_cleanup; + goto err_free_irq; pm_runtime_enable(csi2rx->dev); ret = v4l2_async_register_subdev(&csi2rx->subdev); @@ -1011,6 +1011,9 @@ static int csi2rx_probe(struct platform_device *pdev) err_free_state: v4l2_subdev_cleanup(&csi2rx->subdev); pm_runtime_disable(csi2rx->dev); +err_free_irq: + if (csi2rx->error_irq >= 0) + devm_free_irq(csi2rx->dev, csi2rx->error_irq, csi2rx); err_cleanup: v4l2_async_nf_unregister(&csi2rx->notifier); v4l2_async_nf_cleanup(&csi2rx->notifier); @@ -1030,6 +1033,8 @@ static void csi2rx_remove(struct platform_device *pdev) v4l2_subdev_cleanup(&csi2rx->subdev); media_entity_cleanup(&csi2rx->subdev.entity); pm_runtime_disable(csi2rx->dev); + if (csi2rx->error_irq >= 0) + devm_free_irq(csi2rx->dev, csi2rx->error_irq, csi2rx); kfree(csi2rx); }