public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] media: nuvoton: npcm-video: fix error handling in npcm_video_init()
@ 2026-03-27 22:19 David Carlier
  2026-03-27 22:19 ` [PATCH 2/2] media: nuvoton: npcm-video: fix memory leaks in probe and remove David Carlier
  2026-03-28 14:46 ` [PATCH v2 1/2] media: nuvoton: npcm-video: fix error handling in npcm_video_init() David Carlier
  0 siblings, 2 replies; 4+ messages in thread
From: David Carlier @ 2026-03-27 22:19 UTC (permalink / raw)
  To: kwliu, kflin, mchehab; +Cc: linux-media, openbmc, linux-kernel, David Carlier

npcm_video_init() has two error handling issues after
of_reserved_mem_device_init() is called:

When dma_set_mask_and_coherent() fails, the function releases the
reserved memory but does not return, allowing execution to fall through
into npcm_video_ece_init() with a failed DMA configuration.

When npcm_video_ece_init() fails, the function returns an error without
calling of_reserved_mem_device_release(), leaking the reserved memory
association.

Fix both by adding the missing return after the DMA mask failure and
adding the missing of_reserved_mem_device_release() call on the ECE init
error path.

Fixes: 7c3a5e744482 ("media: nuvoton: Add driver for NPCM video capture/encode engine")
Signed-off-by: David Carlier <devnexen@gmail.com>
---
 drivers/media/platform/nuvoton/npcm-video.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/nuvoton/npcm-video.c b/drivers/media/platform/nuvoton/npcm-video.c
index b2a562e1ee1c..5c6bddfe8073 100644
--- a/drivers/media/platform/nuvoton/npcm-video.c
+++ b/drivers/media/platform/nuvoton/npcm-video.c
@@ -1720,10 +1720,12 @@ static int npcm_video_init(struct npcm_video *video)
 	if (rc) {
 		dev_err(dev, "Failed to set DMA mask\n");
 		of_reserved_mem_device_release(dev);
+		return rc;
 	}
 
 	rc = npcm_video_ece_init(video);
 	if (rc) {
+		of_reserved_mem_device_release(dev);
 		dev_err(dev, "Failed to initialize ECE\n");
 		return rc;
 	}
-- 
2.53.0


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

end of thread, other threads:[~2026-03-28 15:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-27 22:19 [PATCH 1/2] media: nuvoton: npcm-video: fix error handling in npcm_video_init() David Carlier
2026-03-27 22:19 ` [PATCH 2/2] media: nuvoton: npcm-video: fix memory leaks in probe and remove David Carlier
2026-03-28 14:47   ` [PATCH v2 " David Carlier
2026-03-28 14:46 ` [PATCH v2 1/2] media: nuvoton: npcm-video: fix error handling in npcm_video_init() David Carlier

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