public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: davinci: vpif: Fix memory leak in probe error path
@ 2025-04-11 19:48 Dmitry Nikiforov
  2025-04-14  7:56 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Nikiforov @ 2025-04-11 19:48 UTC (permalink / raw)
  To: Lad, Prabhakar
  Cc: Dmitry Nikiforov, Mauro Carvalho Chehab, Hans Verkuil,
	Johan Hovold, linux-media, linux-kernel, lvc-project

If an error occurs during the initialization of `pdev_display`,
the allocated platform device `pdev_capture` is not released properly,
leading to a memory leak.

Fix this by adding `platform_device_del(pdev_capture)` in the error path.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 43acb728bbc4 ("media: davinci: vpif: fix use-after-free on driver unbind")
Signed-off-by: Dmitry Nikiforov <Dm1tryNk@yandex.ru>
---
 drivers/media/platform/ti/davinci/vpif.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/ti/davinci/vpif.c b/drivers/media/platform/ti/davinci/vpif.c
index a81719702a22..d803631072c4 100644
--- a/drivers/media/platform/ti/davinci/vpif.c
+++ b/drivers/media/platform/ti/davinci/vpif.c
@@ -527,6 +527,7 @@ static int vpif_probe(struct platform_device *pdev)
 
 err_put_pdev_display:
 	platform_device_put(pdev_display);
+	platform_device_del(pdev_capture);
 err_put_pdev_capture:
 	platform_device_put(pdev_capture);
 err_put_rpm:
-- 
2.49.0


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

* Re: [PATCH] media: davinci: vpif: Fix memory leak in probe error path
  2025-04-11 19:48 [PATCH] media: davinci: vpif: Fix memory leak in probe error path Dmitry Nikiforov
@ 2025-04-14  7:56 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2025-04-14  7:56 UTC (permalink / raw)
  To: Dmitry Nikiforov
  Cc: Lad, Prabhakar, Mauro Carvalho Chehab, Hans Verkuil, linux-media,
	linux-kernel, lvc-project

On Fri, Apr 11, 2025 at 10:48:17PM +0300, Dmitry Nikiforov wrote:
> If an error occurs during the initialization of `pdev_display`,
> the allocated platform device `pdev_capture` is not released properly,
> leading to a memory leak.
> 
> Fix this by adding `platform_device_del(pdev_capture)` in the error path.

Good catch, but you should fix up the error path above this one
(kzalloc) as part of this patch as well.

Johan

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

end of thread, other threads:[~2025-04-14  7:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 19:48 [PATCH] media: davinci: vpif: Fix memory leak in probe error path Dmitry Nikiforov
2025-04-14  7:56 ` Johan Hovold

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