]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (8414): videodev/cx18: fix get_index bug and error-handling lock-ups
authorHans Verkuil <hverkuil@xs4all.nl>
Fri, 18 Jul 2008 13:07:10 +0000 (10:07 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sun, 20 Jul 2008 10:29:27 +0000 (07:29 -0300)
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>
drivers/media/video/cx18/cx18-streams.c
drivers/media/video/videodev.c

index f3d20509a8bd0fd0f975fce2662f7d0e620277a8..1728b1d832a9ca2eef5f147553da2e1d97a9e4f3 100644 (file)
@@ -311,8 +311,10 @@ void cx18_streams_cleanup(struct cx18 *cx, int unregister)
 
        /* 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;
 
index aca36dec67468d110ef47577119bb36dd3841bbb..6616e6570557b84960d89afc2753e7bf4bf053f0 100644 (file)
@@ -2023,7 +2023,7 @@ EXPORT_SYMBOL(video_ioctl2);
 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
@@ -2145,14 +2145,15 @@ int video_register_device_index(struct video_device *vfd, int type, int nr,
        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 */