• Dave Jones's avatar
    [PATCH] videodev fixups / generic usercopy helper · 97752344
    Dave Jones authored
    Originally from Gerd...
    
    I've just noticed that a hole left in the recent changes which should
    allow the usb v4l drivers to unregister with open file handles.  The
    drivers itself handle it just fine, but video_generic_ioctl() will barf
    when called on unregistered devices.  Oops.
    
    One way to fix this is to expect drivers call the helper function and
    pass a pointer for the function doing the actual work, i.e. handle it
    this way:
    
    driver_ioctl(inode,file,cmd,userptr)
    	-> video_usercopy(inode,file,cmd,userptr,func)
    		copy_from_user(...)
    		-> func(inode,file,cmd,kernelptr);
    		copy_to_user(...)
    
    Patch against 2.5.7-pre2 below. It updates videodev.[ch] and adapts
    usbvideo.c to show how the driver changes will look like.
    
    Note that this change makes the usercopy helper function a very generic
    one, it probably could be used for other drivers to (as long as the API
    has sane magic numbers based on _IO*(...) defines) as there is no
    video4linux-related stuff in there any more.  So we might think of
    renaming it an moving it to some more central place (fs/ioctl.c maybe).
    97752344
videodev.c 11.8 KB