mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: imagination: Release m2m device on probe failure
@ 2026-11-03  9:46 Wentao Liang
  2026-11-03 10:26 ` Krzysztof Kozlowski
  2026-11-05 14:24 ` Thakkar, Devarsh
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-03  9:46 UTC (permalink / raw)
  To: Devarsh Thakkar, Mauro Carvalho Chehab
  Cc: linux-media, linux-kernel, Wentao Liang, stable

e5010_probe() initializes the mem2mem device after registering the v4l2
device. When mapping the "core" or "mmu" register region, requesting the
IRQ or getting the clock fails, the error path jumps to the
fail_after_v4l2_register label, which only unregisters the v4l2 device.
The v4l2_m2m_dev allocated by v4l2_m2m_init() is not released, so it
leaks on these probe failures.

Release the m2m device from that label as well, so that every error path
taken after v4l2_m2m_init() succeeds frees it. v4l2_m2m_release() accepts
a NULL pointer, so the v4l2_m2m_init() failure path is unaffected.

Fixes: a1e294045885 ("media: imagination: Add E5010 JPEG Encoder driver")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/media/platform/imagination/e5010-jpeg-enc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.c
index 420cb8bfdb12..49943bd604da 100644
--- a/drivers/media/platform/imagination/e5010-jpeg-enc.c
+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c
@@ -1104,7 +1104,7 @@ static int e5010_probe(struct platform_device *pdev)
 	ret = video_register_device(e5010->vdev, VFL_TYPE_VIDEO, 0);
 	if (ret) {
 		dev_err_probe(dev, ret, "failed to register video device\n");
-		goto fail_after_video_register_device;
+		goto fail_after_v4l2_register;
 	}
 
 	v4l2_info(&e5010->v4l2_dev, "Device registered as /dev/video%d\n",
@@ -1112,9 +1112,8 @@ static int e5010_probe(struct platform_device *pdev)
 
 	return 0;
 
-fail_after_video_register_device:
-	v4l2_m2m_release(e5010->m2m_dev);
 fail_after_v4l2_register:
+	v4l2_m2m_release(e5010->m2m_dev);
 	v4l2_device_unregister(&e5010->v4l2_dev);
 fail_after_video_device_alloc:
 	video_device_release(e5010->vdev);
-- 
2.34.1


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

end of thread, other threads:[~2026-11-05 14:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03  9:46 [PATCH] media: imagination: Release m2m device on probe failure Wentao Liang
2026-11-03 10:26 ` Krzysztof Kozlowski
2026-11-05 14:24 ` Thakkar, Devarsh

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

all inboxes | Powered by JetHome®