Fix a bug in get_index that was introduced earlier.
Also fix two error handling lock-ups in videodev and cx18 that
where found thanks to that bug.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
/* Teardown all streams */
for (type = 0; type < CX18_MAX_STREAMS; type++) {
- if (cx->streams[type].dvb.enabled)
+ if (cx->streams[type].dvb.enabled) {
cx18_dvb_unregister(&cx->streams[type]);
+ cx->streams[type].dvb.enabled = false;
+ }
vdev = cx->streams[type].v4l2dev;
static int get_index(struct video_device *vdev, int num)
{
u32 used = 0;
- const unsigned max_index = sizeof(used) * 8 - 1;
+ const int max_index = sizeof(used) * 8 - 1;
int i;
/* Currently a single v4l driver instance cannot create more than
vfd->minor=i;
ret = get_index(vfd, index);
+ vfd->index = ret;
+
+ mutex_unlock(&videodev_lock);
+
if (ret < 0) {
printk(KERN_ERR "%s: get_index failed\n", __func__);
goto fail_minor;
}
- vfd->index = ret;
-
- mutex_unlock(&videodev_lock);
mutex_init(&vfd->lock);
/* sysfs class */