On Sun, 27 Nov 2005, Ville Syrjälä wrote: > > I suspect you are triggering a bug in the input layer. Adding a few > > debugging lines to the test driver, particularly in usbtest_delete, might > > help pinpoint the bug. > > It explodes when I call input_free_device() which just a wrapper for > kfree(). And now I see the reason for the double free. > input_dev_release() also does kfree() on the input_dev. > > So the question is: Why does input_free_device() even exist?
You should ask Dmitry Torokhov (CC'ed). > > > static int usbtest_probe(struct usb_interface *interface, const struct > > > usb_device_id *id) > > > { > > > struct usb_device *udev = interface_to_usbdev(interface); > > > struct usbtest *ut; > > > int r; > > > > > > ut = kzalloc(sizeof (struct usbtest), GFP_KERNEL); > > > if (!ut) > > > return -ENOMEM; > > > > > > ut->udev = udev; > > > usb_make_path(udev, ut->phys, sizeof(ut->phys)); > > > strlcat(ut->phys, "/input0", sizeof(ut->phys)); > > > > > > strlcat(ut->name, "usbtest", sizeof(ut->name)); > > > > > > r = usbtest_input_init(ut); > > > if (r) > > > goto error; > > > > So you try to deregister the input device even if it failed to register? > > Is that legal? (Although that's not what caused the oops in this case.) > > I don't really know. It looks like input_unregister_device() cleans up > after both input_allocate_device() and input_register_device(). > > Actually input_device_register() can't actually fail so checking the > return value isn't really needed. > > > > usb_set_intfdata(interface, ut); > > > > In a real driver, you would probably want to do this before registering > > the input device. > > Really? Most drivers do it as the very last thing in the probe() > callback. As soon as you register the input device, your callbacks may be invoked. If any of those callbacks need to get at the interface's driver data, you will have to call usb_set_intfdata before calling usbtest_input_init. Of course, if the callbacks don't use the driver data then the order doesn't matter. Alan Stern ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel