Hi Hans,

On Tuesday 23 November 2010 10:47:10 Hans Verkuil wrote:
> On Tuesday, November 23, 2010 01:21:45 Laurent Pinchart wrote:
> > On Tuesday 23 November 2010 01:14:28 Hans Verkuil wrote:
> > > 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.
> > 
> > device_unregister() will end up calling v4l2_device_release(), which also
> > locks videodev_lock. That will result in a deadlock.
> 
> True. (Note to myself: don't post past midnight...)
> 
> But a mutex around clear_bit doesn't help either. Unless v4l2_open will
> test for this bit just before the video_get(). E.g. by replacing 'if (vdev
> == NULL)' with 'if (vdev == NULL || !video_is_registered(vdev))'.
> 
> I think that will do the trick.

Sounds good to me. Do you want to submit a patch ? :-)

-- 
Regards,

Laurent Pinchart
--
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