From: Sebastian Reichel Date: Tue, 14 Feb 2017 22:38:49 +0000 (-0200) Subject: [media] v4l: Allow calling v4l2_device_register_subdev_nodes() multiple times X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=db0f4691d9749d5dd758b8636290cec8fd88aa26;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [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 --- 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;