LKML Archive on
help / color / mirror / Atom feed
* [PATCH] media: vim2m: fix two double-free issues
@ 2019-05-13  7:18 Kefeng Wang
  0 siblings, 0 replies; only message in thread
From: Kefeng Wang @ 2019-05-13  7:18 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Kefeng Wang, Hans Verkuil, Laurent Pinchart,
	Mauro Carvalho Chehab, Hulk Robot

vim2m_device_release() will be called by video_unregister_device() to release
various objects.

There are two double-free issue,
1. dev->m2m_dev will be freed twice in error_m2m path/vim2m_device_release
2. the error_v4l2 and error_free path in vim2m_probe() will release
   same objects, since vim2m_device_release has done.

Cc: Hans Verkuil <>
Cc: Laurent Pinchart <>
Cc: Mauro Carvalho Chehab <>
Reported-by: Hulk Robot <>
Fixes: ea6c7e34f3b2 ("media: vim2m: replace devm_kzalloc by kzalloc")
Signed-off-by: Kefeng Wang <>
 drivers/media/platform/vim2m.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index 243c82b5d537..acd3bd48c7e2 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -1359,7 +1359,7 @@ static int vim2m_probe(struct platform_device *pdev)
 	if (ret) {
 		v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller\n");
-		goto error_m2m;
+		goto error_dev;
 	ret = media_device_register(&dev->mdev);
@@ -1373,11 +1373,11 @@ static int vim2m_probe(struct platform_device *pdev)
-	v4l2_m2m_release(dev->m2m_dev);
+	/* vim2m_device_release called by video_unregister_device to release various objects */
+	return ret;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-13  7:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-13  7:18 [PATCH] media: vim2m: fix two double-free issues Kefeng Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).