On Monday, November 22, 2010 12:20:25 Hans Verkuil wrote:
> On Monday, November 22, 2010 11:21:27 Laurent Pinchart wrote:
> > Removing the mutex_lock/unlock around clear_bit allowed
> > device_unregister() to race with v4l2_open(). The device can be
> > unregistered  between the video_devdata() and video_get() calls.
> > 
> > Revert the patch to fix the problem.
> > 
> > This reverts commit dd0daf2a6fb6bec436a3ef68bd585ea09a2a54b7.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
> 
> Acked-by: Hans Verkuil <hverk...@xs4all.nl>

Change of mind, I nack this.

I realized that the mutex should be around device_unregister, not around the
clear_bit. The mutex protects access to vdev->dev and not vdev->flags since 
that's
atomic anyway.

Regards,

        Hans

> 
> > ---
> >  drivers/media/video/v4l2-dev.c |    2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
> > index 03f7f46..f777da6 100644
> > --- a/drivers/media/video/v4l2-dev.c
> > +++ b/drivers/media/video/v4l2-dev.c
> > @@ -596,7 +596,9 @@ void video_unregister_device(struct video_device *vdev)
> >     if (!vdev || !video_is_registered(vdev))
> >             return;
> >  
> > +   mutex_lock(&videodev_lock);
> >     clear_bit(V4L2_FL_REGISTERED, &vdev->flags);
> > +   mutex_unlock(&videodev_lock);
> >     device_unregister(&vdev->dev);
> >  }
> >  EXPORT_SYMBOL(video_unregister_device);
> > 
> 
> 

-- 
Hans Verkuil - video4linux developer - sponsored by Cisco
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to