Re: device_remove_file and disconnect

From: matthieu castet (castet.matthieu_at_free.fr)
Date: 07/03/05

  • Next message: Daniel Drake: "Re: Problem with inotify"
    Date:	Sun, 03 Jul 2005 01:27:53 +0200
    To: Greg KH <greg@kroah.com>
    
    

    Hi,
    matthieu castet wrote:
    >>
    >>
    >> Then they should be fixed. Any specific examples?
    >>
    >>
    > I am a little lasy to list all, but some drivers in driver/usb should
    > have this problem : the first driver I look : ./misc/phidgetkit.c do
    > [1]. So sysfs read don't check if to_usb_interface or usb_get_intfdata
    > return NULL pointer...
    > And it is a bit your fault, as many developper should have read your
    > great tutorial [2] ;)
    >
    >>> Also I always see driver free their privatre data in device disconnect,
    >>> so if read/write from sysfs aren't serialized with device disconnect
    >>> there are still a possible race like I show in my example.
    >>
    >>
    >>
    >> Yes, you are correct. Again, any specific drivers you see with this
    >> problem?
    >
    > I believe near all drivers that use sysfs via device_create_file, as I
    > never see them use mutex in read/write in order to check there aren't in
    > the same time in their disconnect that could free there private data
    > when they do operation on it...
    >
    >
    > Couldn't be possible the make device_remove_file blocking until all the
    > open file are closed ?
    >
    > thanks,
    >
    > Matthieu
    >
    > [1]
    > #define show_input(value) \
    > static ssize_t show_input##value(struct device *dev, char *buf) \
    > { \
    > struct usb_interface *intf = to_usb_interface(dev); \
    > struct phidget_interfacekit *kit = usb_get_intfdata(intf); \
    > \
    > return sprintf(buf, "%d\n", kit->inputs[value - 1]); \
    > } \
    > static DEVICE_ATTR(input##value, S_IRUGO, show_input##value, NULL);
    >
    > [2] http://www.linuxjournal.com/article/7353
    >

    So will there be a fix in the kernel, or all this driver are broken and
    should be fixed ?

    thanks

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


  • Next message: Daniel Drake: "Re: Problem with inotify"

    Relevant Pages

    • Re: 2.6.10-rc2 on VAIO laptop and PowerMac 8500/G3
      ... fbdev layer broke some of those old drivers. ... VT mode data structure, the driver is now sort-of supposed to re-invent ... but I suppose I'll have to fix controlfb (and platinumfb ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • RE: Driver Model 2 Proposal - Linux Kernel Performance v Usability
      ... I agree that it is an extra interface ... > Windows has many faults but drivers are often compatible across ... common users in the Windows world can't handle installing a driver any better than they would be able to in Linux. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [Bug 1412] Copy from USB1 CF/SM reader stalls, no actual content is read (only directory structu
      ... For drivers like this that aren't performance critical and ... > depends on the capabilities of the USB host controller that our device ... and if the result is 0 then calling kmap() ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: HighPoint 374
      ... > I'm using two seagates, one Samsung and one Maxtor, ... > drivers, pretty much everything that does not relate directly to the IDE ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Losing interrupts
      ... > bus to completely freeze until the FIFO had drained. ... at which point they fixed their drivers. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)