On Wed, 1 Jun 2005, Dmitry Torokhov wrote: > > +static ssize_t show_tabletSize(struct device *dev, char *buf) > > +{ > > + struct usb_acecad *acecad = dev_get_drvdata(dev); > > + > > + if (acecad == NULL) > > + return 0; > > This check - is it really needed? Attributes are deleted in > disconnect... Wait, this needs locking because if someone happens to > read one of the attributes while usb_acecad_disconnect is running you > may end up accessing just freed memory, no?
No. Attributes are complex things. When an attribute is opened the sysfs code does kobject_get on the underlying object. The release method won't get called, and hence the memory won't get freed, until the attribute is closed. On the other hand, remove methods typically do call dev_set_drvdata(dev, NULL). Thus a read-during-disconnect might very well end up with acecad == NULL, and so the check above is necessary. Alan Stern ------------------------------------------------------- This SF.Net email is sponsored by Yahoo. Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel