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

From: Hans Verkuil
Date: Mon Oct 18 2010 - 15:40:53 EST


On Monday, October 18, 2010 21:00:57 Mauro Carvalho Chehab wrote:
> Em 15-10-2010 09:23, Hans Verkuil escreveu:
> > On Friday, October 15, 2010 14:05:39 Mauro Carvalho Chehab wrote:
> >> Em 15-10-2010 07:02, Hans Verkuil escreveu:
> >>> On Friday, October 15, 2010 11:05:26 Andrew Morton wrote:
> >>>> On Fri, 15 Oct 2010 10:45:45 +0200 Hans Verkuil <hverkuil@xxxxxxxxx> wrote:
> >>>>
> >>>>> On Thursday, October 14, 2010 22:06:29 Valdis.Kletnieks@xxxxxx wrote:
> >>>>>> On Wed, 13 Oct 2010 17:13:25 PDT, akpm@xxxxxxxxxxxxxxxxxxxx said:
> >>>>>>> The mm-of-the-moment snapshot 2010-10-13-17-13 has been uploaded to
> >>>
> >>> Mauro, is this something for you to fix?
> >>
> >> I have a patch fixing this conflict already:
> >>
> >> http://git.linuxtv.org/mchehab/sbtvd.git?a=commit;h=88164fbe701a0a16e9044b74443dddb6188b54cc
> >>
> >> The patch is currently on a separate tree, that I'm using to test some experimental
> >> drivers for Brazilian Digital TV system (SBTVD). I'm planning to merge this patch, among
> >> with other patches I received for .37 during this weekend.
> >
> > No, this patch isn't sufficient. It backs out the wrong code but doesn't put
> > in the 'video_is_registered()' if statements that were in my original patch.
> >
> > Those are really needed.
>
> Ok, I've re-done the conflict fix patch:
>
> http://git.kernel.org/?p=linux/kernel/git/mchehab/linux-next.git;a=commitdiff;h=f9fccbad2a67668240edeaa6ada5aea2281d10b3

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/