Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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 <sre@kernel.org>
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Sebastian Reichel and committed by
Mauro Carvalho Chehab
db0f4691 974f4a38

+3
+3
drivers/media/v4l2-core/v4l2-device.c
··· 235 235 if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE)) 236 236 continue; 237 237 238 + if (sd->devnode) 239 + continue; 240 + 238 241 vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); 239 242 if (!vdev) { 240 243 err = -ENOMEM;