Re: mmotm 2010-10-13 - GSPCA SPCA561 webcam driver broken

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Hans Verkuil
Date: Monday, October 18, 2010 - 12:39 pm

On Monday, October 18, 2010 21:00:57 Mauro Carvalho Chehab wrote:

I hate to say this, but it is still not right. This is the correct code:

static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
        struct video_device *vdev = video_devdata(filp);
        int ret = -ENODEV;

        if (vdev->fops->unlocked_ioctl) {
                if (vdev->lock)
                        mutex_lock(vdev->lock);
                if (video_is_registered(vdev))
                        ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
                if (vdev->lock)
                        mutex_unlock(vdev->lock);
        } else if (vdev->fops->ioctl) {
                /* TODO: convert all drivers to unlocked_ioctl */
                lock_kernel();
                if (video_is_registered(vdev))
                        ret = vdev->fops->ioctl(filp, cmd, arg);
                unlock_kernel();
        } else
                ret = -ENOTTY;

        return ret;
}

As you can see, the video_is_registered is called with the lock held.

Regards,

	Hans

-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG, part of Cisco
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
mmotm 2010-10-13-17-13 uploaded, akpm, (Wed Oct 13, 5:13 pm)
Re: mmotm 2010-10-13-17-13 uploaded (staging/bcm), Randy Dunlap, (Wed Oct 13, 9:17 pm)
Re: mmotm 2010-10-13-17-13 uploaded (leds), Randy Dunlap, (Wed Oct 13, 9:29 pm)
Re: mmotm 2010-10-13-17-13 uploaded, Zimny Lech, (Thu Oct 14, 3:26 am)
Re: mmotm 2010-10-13-17-13 uploaded (leds), Johannes Berg, (Thu Oct 14, 4:38 am)
Re: mmotm 2010-10-13-17-13 uploaded (leds), Randy Dunlap, (Thu Oct 14, 9:14 am)
Re: mmotm 2010-10-13-17-13 uploaded (staging/bcm), Greg KH, (Thu Oct 14, 12:14 pm)
Re: mmotm 2010-10-13-17-13 uploaded, Andrew Morton, (Thu Oct 14, 12:16 pm)
Re: mmotm 2010-10-13-17-13 uploaded, Zimny Lech, (Thu Oct 14, 12:23 pm)
mmotm 2010-10-13 - GSPCA SPCA561 webcam driver broken, Valdis.Kletnieks, (Thu Oct 14, 1:06 pm)
Re: mmotm 2010-10-13-17-13 uploaded (leds), Johannes Berg, (Thu Oct 14, 1:13 pm)
Re: mmotm 2010-10-13-17-13 uploaded (leds), Randy Dunlap, (Thu Oct 14, 1:32 pm)
Re: mmotm 2010-10-13-17-13 uploaded (staging/bcm), Randy Dunlap, (Thu Oct 14, 1:38 pm)
Re: mmotm 2010-10-13 - GSPCA SPCA561 webcam driver broken, Andrew Morton, (Fri Oct 15, 2:05 am)
Re: mmotm 2010-10-13 - GSPCA SPCA561 webcam driver broken, Mauro Carvalho Chehab, (Fri Oct 15, 5:05 am)
Re: mmotm 2010-10-13 - GSPCA SPCA561 webcam driver broken, Mauro Carvalho Chehab, (Mon Oct 18, 12:00 pm)
Re: mmotm 2010-10-13 - GSPCA SPCA561 webcam driver broken, Hans Verkuil, (Mon Oct 18, 12:39 pm)
ptrace BUG [was: mmotm 2010-10-13-17-13 uploaded], Jiri Slaby, (Wed Oct 20, 8:50 am)
Re: ptrace BUG [was: mmotm 2010-10-13-17-13 uploaded], Peter Zijlstra, (Wed Oct 20, 8:52 am)
Re: ptrace BUG [was: mmotm 2010-10-13-17-13 uploaded], Frederic Weisbecker, (Wed Oct 20, 8:54 am)
Re: ptrace BUG [was: mmotm 2010-10-13-17-13 uploaded], Peter Zijlstra, (Wed Oct 20, 9:13 am)
Re: ptrace BUG [was: mmotm 2010-10-13-17-13 uploaded], Jiri Slaby, (Wed Oct 20, 10:29 am)
Re: ptrace BUG [was: mmotm 2010-10-13-17-13 uploaded], Jiri Slaby, (Thu Oct 21, 12:34 am)
Re: ptrace BUG [was: mmotm 2010-10-13-17-13 uploaded], Peter Zijlstra, (Thu Oct 21, 12:40 am)
Re: mmotm 2010-10-13-17-13 uploaded (leds), Johannes Berg, (Tue Oct 26, 3:14 am)