diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2016-08-11 07:18:37 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-08-24 16:47:24 -0300 |
commit | fc49071766ed371268cc03b868cf97f21ad3f273 (patch) | |
tree | 1325d101809ddb8b063f2dcb2d829fa4deb7a290 /drivers/media/v4l2-core | |
parent | 6a21b728732390deb75536dd9253d958ca9223d0 (diff) | |
download | linux-fc49071766ed371268cc03b868cf97f21ad3f273.tar.gz linux-fc49071766ed371268cc03b868cf97f21ad3f273.tar.bz2 linux-fc49071766ed371268cc03b868cf97f21ad3f273.zip |
[media] v4l: Do not allow re-registering sub-devices
Albeit not prohibited explicitly, re-registering sub-devices generated a
big, loud warning which quite likely soon was followed by a crash. What
followed was re-initialising a media entity, driver's registered() callback
being called and re-adding a list entry to a list.
Prevent this by returning an error if a sub-device is already registered.
[mchehab@s-opensource.com: reorder logic to check if !sd before dereferencing it]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-device.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index 06fa5f1b2cff..62bbed76dbbc 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -160,12 +160,9 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, int err; /* Check for valid input */ - if (v4l2_dev == NULL || sd == NULL || !sd->name[0]) + if (!v4l2_dev || !sd || sd->v4l2_dev || !sd->name[0]) return -EINVAL; - /* Warn if we apparently re-register a subdev */ - WARN_ON(sd->v4l2_dev != NULL); - /* * The reason to acquire the module here is to avoid unloading * a module of sub-device which is registered to a media |