blob: 9c383b20d96dac7ccfb8fbf40ddf250a7b1762d2 [file] [log] [blame]
From 4006875203f6ddfab919953cf575f63e751c5214 Mon Sep 17 00:00:00 2001
From: Dafna Hirschfeld <>
Date: Wed, 19 Feb 2020 16:25:54 +0100
Subject: [PATCH] media: v4l2-core: fix a use-after-free bug of sd->devnode
commit 6990570f7e0a6078e11b9c5dc13f4b6e3f49a398 upstream.
sd->devnode is released after calling
v4l2_subdev_release. Therefore it should be set
to NULL so that the subdev won't hold a pointer
to a released object. This fixes a reference
after free bug in function
Fixes: 0e43734d4c46e ("media: v4l2-subdev: add release() internal op")
Signed-off-by: Dafna Hirschfeld <>
Reviewed-by: Ezequiel Garcia <>
Signed-off-by: Hans Verkuil <>
Signed-off-by: Mauro Carvalho Chehab <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
index aa277f5bc862..7fd8f2facc94 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -210,6 +210,7 @@ static void v4l2_subdev_release(struct v4l2_subdev *sd)
if (sd->internal_ops && sd->internal_ops->release)
+ sd->devnode = NULL;