[PATCH v3 2/2] media: rcar-isp: release the core interrupt before destroying RPPX1
From: Myeonghun Pak
Date: Sat Oct 17 2026 - 22:48:05 EST
core->rpp is a separately allocated struct rppx1: rppx1_create()
allocates it with kzalloc_obj(), and rppx1_destroy() frees it with
kfree(). It is not part of the device-managed core allocation.
risp_core_irq() calls rppx1_interrupt(core->rpp, ...) before taking
core->lock. rppx1_interrupt() accesses rpp->base through rppx1_read()
and rppx1_write(), and can also use rpp->dev. An interrupt handler that
has passed the ISPCORE status check can still be using this object when
risp_core_remove() frees it. Stopping the video queues and taking
core->lock do not join that earlier part of the handler. The managed IRQ
is otherwise released only after remove returns.
Request the IRQ after the RPPX1 object, subdevice, locks and job list have
been initialized, so probe error paths cannot leave a handler using an
uninitialized or freed RPPX1 object. Release and synchronize the IRQ after
stopping the I/O nodes but before unregistering the V4L2 device and
destroying RPPX1.
This issue was identified during our ongoing research while reviewing
kernel code.
Fixes: 2151350f60d1 ("media: rcar-isp: Add support for ISPCORE")
Assisted-by: LLM
Co-developed-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
---
Changes in v3:
- No code changes relative to v2.
Changes in v2:
- Identify the separately allocated RPPX1 object and the rpp->base/rpp->dev
accesses in the interrupt handler, rather than the core lock lifetime.
- Move -ENODEV handling into a separate prerequisite patch.
- No code changes relative to the IRQ portion of v1.
Compile-tested with Clang 22.1.2, W=1 (arm64). No runtime testing.
drivers/media/platform/renesas/rcar-isp/core.c | 13 +++++++++----
drivers/media/platform/renesas/rcar-isp/risp-core.h | 2 ++
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/renesas/rcar-isp/core.c b/drivers/media/platform/renesas/rcar-isp/core.c
index 373d9ca9374fe..78cbb549fd18f 100644
--- a/drivers/media/platform/renesas/rcar-isp/core.c
+++ b/drivers/media/platform/renesas/rcar-isp/core.c
@@ -802,10 +802,7 @@ static int risp_core_probe_resources(struct rcar_isp_core *core,
if (ret < 0)
return -ENODEV;
- ret = devm_request_irq(&pdev->dev, ret, risp_core_irq, IRQF_SHARED,
- KBUILD_MODNAME, core);
- if (ret)
- return ret;
+ core->irq = ret;
core->clk = devm_clk_get(&pdev->dev, "core");
if (IS_ERR(core->clk))
@@ -887,8 +884,15 @@ int risp_core_probe(struct rcar_isp_core *core, struct platform_device *pdev,
spin_lock_init(&core->lock);
INIT_LIST_HEAD(&core->risp_jobs);
+ ret = devm_request_irq(core->dev, core->irq, risp_core_irq, IRQF_SHARED,
+ KBUILD_MODNAME, core);
+ if (ret)
+ goto err_destroy_mutex;
+
return 0;
+err_destroy_mutex:
+ mutex_destroy(&core->io_lock);
err_unregister_v4l2:
v4l2_device_unregister(&core->v4l2_dev);
err_destroy_rpp:
@@ -909,6 +913,7 @@ void risp_core_remove(struct rcar_isp_core *core)
for (unsigned int i = 0; i < RISP_CORE_NUM_PADS; i++)
risp_core_io_destroy(&core->io[i]);
+ devm_free_irq(core->dev, core->irq, core);
v4l2_device_unregister(&core->v4l2_dev);
mutex_destroy(&core->io_lock);
diff --git a/drivers/media/platform/renesas/rcar-isp/risp-core.h b/drivers/media/platform/renesas/rcar-isp/risp-core.h
index 627a762d6b192..70432cf4a88ca 100644
--- a/drivers/media/platform/renesas/rcar-isp/risp-core.h
+++ b/drivers/media/platform/renesas/rcar-isp/risp-core.h
@@ -112,6 +112,7 @@ struct rcar_isp_vspx {
* @dev: (OF) device
* @rppaddr: Hardware address of the RPP ISP (from OF)
* @clk: The clock for the ISP CORE
+ * @irq: Interrupt for the ISP CORE
* @rstc: The reset for the ISP Core
* @csrstc: The reset for the ISP Channel Selector
*
@@ -138,6 +139,7 @@ struct rcar_isp_core {
u32 rppaddr;
struct clk *clk;
+ int irq;
struct reset_control *rstc;
struct reset_control *csrstc;