From db0f4691d9749d5dd758b8636290cec8fd88aa26 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Tue, 14 Feb 2017 20:38:49 -0200 Subject: [PATCH] [media] v4l: Allow calling v4l2_device_register_subdev_nodes() multiple times Previously multiple calls to v4l2_device_register_subdev_nodes() ended up corrupting memory and leaking some, too. This patch changes the behaviour so that sub-devices the device nodes of which are already registered are ignored. Signed-off-by: Sebastian Reichel Signed-off-by: Ivaylo Dimitrov Signed-off-by: Pavel Machek Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index f364cc1b521d..937c6de85606 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -235,6 +235,9 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE)) continue; + if (sd->devnode) + continue; + vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); if (!vdev) { err = -ENOMEM; -- 2.20.1