Re: [patchset] Lockfree fd lookup 2 of 5

Ravikiran G Thirumalai
2004-08-03T07:42:54Z

On Mon, Aug 02, 2004 at 11:44:24PM -0700, Greg KH wrote:
> On Mon, Aug 02, 2004 at 03:46:06PM +0530, Ravikiran G Thirumalai wrote:
> > diff -ruN -X dontdiff2 linux-2.6.7/drivers/usb/core/message.c kref-2.6.7/drivers/usb/core/message.c
> > --- linux-2.6.7/drivers/usb/core/message.c 2004-06-16 10:49:02.000000000 +0530
> > +++ kref-2.6.7/drivers/usb/core/message.c 2004-07-20 15:07:24.000000000 +0530
> > @@ -1077,11 +1077,12 @@
> >
> > static void release_interface(struct device *dev)
> > {
> > + extern void destroy_serial(struct kref *kref);
> > struct usb_interface *intf = to_usb_interface(dev);
> > struct usb_interface_cache *intfc =
> > altsetting_to_usb_interface_cache(intf->altsetting);
> >
> > - kref_put(&intfc->ref);
> > + kref_put(&intfc->ref, destroy_serial);
> > kfree(intf);
> > }
>
> This is the bug. destroy_serial() is for the usb_serial core and does
> not clean up for this type of structure (and is not exported, so it will
> not even build properly). Also, never put a function prototype within a
> function like you did here.
>
> So, I'm guessing you didn't try to remove any USB devices after applying
> your patch? :)

No I didn't :). I just checked the build not the working as such.
>From what I could infer from the 2.6.7 tree, there is no kref_init()
in core/message.c. Well I dunno what made me think destroy_serial
was used to init (kref_init) that refcounter at that time so I have
even exported destroy_serial in the patch so that it builds.
(expored as in changing static to non static .. I build all drivers
into the kernel usually and so the build didn't break for me).
I now realise destroy_serial is the wrong release function. I am no expert
in usb-drivers area, but I should be more careful than that.

Thanks,
Kiran