The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/2] staging: media: ipu7: fix pm_runtime refcount leaks
@ 2026-07-04  8:30 Vidhu Sarwal
  2026-07-04  8:30 ` [PATCH 1/2] staging: media: ipu7: fix pm_runtime refcount leak in ipu7_init_fw_code_region_by_sys() Vidhu Sarwal
  2026-07-04  8:30 ` [PATCH 2/2] staging: media: ipu7: fix pm_runtime refcount leak in ipu7_resume() Vidhu Sarwal
  0 siblings, 2 replies; 3+ messages in thread
From: Vidhu Sarwal @ 2026-07-04  8:30 UTC (permalink / raw)
  To: sakari.ailus, linux-media
  Cc: bingbu.cao, mchehab, gregkh, linux-staging, linux-kernel, skhan,
	kernel-mentees, Vidhu Sarwal

pm_runtime_get_sync() is used in two places in the ipu7 driver before
accessing the device. If runtime PM resume fails, the usage count
remains incremented, but both error paths return without dropping the
reference.

Use pm_runtime_resume_and_get() instead, which balances the usage count
on failure and avoids the leaked runtime PM references. This matches the
equivalent code in the ipu6 driver.

Vidhu Sarwal (2):
  staging: media: ipu7: fix pm_runtime refcount leak in
    ipu7_init_fw_code_region_by_sys()
  staging: media: ipu7: fix pm_runtime refcount leak in ipu7_resume()

 drivers/staging/media/ipu7/ipu7.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.53.0


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

* [PATCH 1/2] staging: media: ipu7: fix pm_runtime refcount leak in ipu7_init_fw_code_region_by_sys()
  2026-07-04  8:30 [PATCH 0/2] staging: media: ipu7: fix pm_runtime refcount leaks Vidhu Sarwal
@ 2026-07-04  8:30 ` Vidhu Sarwal
  2026-07-04  8:30 ` [PATCH 2/2] staging: media: ipu7: fix pm_runtime refcount leak in ipu7_resume() Vidhu Sarwal
  1 sibling, 0 replies; 3+ messages in thread
From: Vidhu Sarwal @ 2026-07-04  8:30 UTC (permalink / raw)
  To: sakari.ailus, linux-media
  Cc: bingbu.cao, mchehab, gregkh, linux-staging, linux-kernel, skhan,
	kernel-mentees, Vidhu Sarwal

ipu7_init_fw_code_region_by_sys() calls pm_runtime_get_sync() before
accessing the firmware code region. If resuming the device fails,
pm_runtime_get_sync() leaves the runtime PM usage count incremented,
but the error path returns without dropping the reference.

Use pm_runtime_resume_and_get() instead, which balances the usage count
automatically on failure and avoids the leak.

The ipu6 driver uses pm_runtime_resume_and_get() in the equivalent
location.

Fixes: b7fe4c0019b1 ("media: staging/ipu7: add Intel IPU7 PCI device driver")
Signed-off-by: Vidhu Sarwal <vidhu.linux@gmail.com>
---
 drivers/staging/media/ipu7/ipu7.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/ipu7/ipu7.c b/drivers/staging/media/ipu7/ipu7.c
index 310e3f24e571..056af3a07507 100644
--- a/drivers/staging/media/ipu7/ipu7.c
+++ b/drivers/staging/media/ipu7/ipu7.c
@@ -2343,7 +2343,7 @@ static int ipu7_init_fw_code_region_by_sys(struct ipu7_bus_device *sys,
 		return ret;
 	}
 
-	ret = pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
 	if (ret < 0) {
 		dev_err(dev, "Failed to get runtime PM\n");
 		return ret;
-- 
2.53.0


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

* [PATCH 2/2] staging: media: ipu7: fix pm_runtime refcount leak in ipu7_resume()
  2026-07-04  8:30 [PATCH 0/2] staging: media: ipu7: fix pm_runtime refcount leaks Vidhu Sarwal
  2026-07-04  8:30 ` [PATCH 1/2] staging: media: ipu7: fix pm_runtime refcount leak in ipu7_init_fw_code_region_by_sys() Vidhu Sarwal
@ 2026-07-04  8:30 ` Vidhu Sarwal
  1 sibling, 0 replies; 3+ messages in thread
From: Vidhu Sarwal @ 2026-07-04  8:30 UTC (permalink / raw)
  To: sakari.ailus, linux-media
  Cc: bingbu.cao, mchehab, gregkh, linux-staging, linux-kernel, skhan,
	kernel-mentees, Vidhu Sarwal

ipu7_resume() calls pm_runtime_get_sync() before resuming the device.
If the runtime PM resume fails, the usage count remains incremented, but
the error path returns without dropping the reference.

Use pm_runtime_resume_and_get() instead, which balances the usage count
on failure and avoids the leak. Keep returning 0 on error, as resume
callbacks should not propagate failures to the PM core, matching the
behaviour of the ipu6 driver.

Fixes: b7fe4c0019b1 ("media: staging/ipu7: add Intel IPU7 PCI device driver")
Signed-off-by: Vidhu Sarwal <vidhu.linux@gmail.com>
---
 drivers/staging/media/ipu7/ipu7.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/ipu7/ipu7.c b/drivers/staging/media/ipu7/ipu7.c
index 056af3a07507..48a35bda4237 100644
--- a/drivers/staging/media/ipu7/ipu7.c
+++ b/drivers/staging/media/ipu7/ipu7.c
@@ -2702,7 +2702,7 @@ static int ipu7_resume(struct device *dev)
 	if (ret)
 		dev_err(dev, "IPC reset protocol failed!\n");
 
-	ret = pm_runtime_get_sync(&isp->psys->auxdev.dev);
+	ret = pm_runtime_resume_and_get(&isp->psys->auxdev.dev);
 	if (ret < 0) {
 		dev_err(dev, "Failed to get runtime PM\n");
 		return 0;
-- 
2.53.0


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

end of thread, other threads:[~2026-07-04  8:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-04  8:30 [PATCH 0/2] staging: media: ipu7: fix pm_runtime refcount leaks Vidhu Sarwal
2026-07-04  8:30 ` [PATCH 1/2] staging: media: ipu7: fix pm_runtime refcount leak in ipu7_init_fw_code_region_by_sys() Vidhu Sarwal
2026-07-04  8:30 ` [PATCH 2/2] staging: media: ipu7: fix pm_runtime refcount leak in ipu7_resume() Vidhu Sarwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox