Sarah Sharp wrote: > On Wed, Jan 16, 2013 at 12:22:59PM -0500, Alan Stern wrote: >> On Wed, 16 Jan 2013, Martin Mokrejs wrote: >> >>> A corresponding diff of dmesg output is attached. Note that the first kmemleak in there >>> happened just without any prior fiddling with a USB drive. For about two days I haven't >>> connected a drive. However, usb-storage might be in a wrong shape since several days >>> when it happened for the first time. Did you want me to reboot? ;-) I did not. >> >> Sarah, I looked through the xhci-hcd driver. There does appear to be a >> leak in xhci-ring.c:handle_tx_event(). > > Thanks for catching that. > >> The routine looks like this: >> >> /* Leave the TD around for the reset endpoint function >> * to use(but only if it's not a control endpoint, >> * since we already queued the Set TR dequeue pointer >> * command for stalled control endpoints). >> */ >> if (usb_endpoint_xfer_control(&urb->ep->desc) || >> (trb_comp_code != COMP_STALL && >> trb_comp_code != COMP_BABBLE)) >> xhci_urb_free_priv(xhci, urb_priv); >> >> ... >> >> /* EHCI, UHCI, and OHCI always unconditionally set the >> * urb->status of an isochronous endpoint to 0. >> */ >> if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) >> status = 0; >> usb_hcd_giveback_urb(bus_to_hcd(urb->dev->bus), urb, status); >> >> If the condition on the first "if" statement fails, urb_priv won't be >> deallocated. It needs something like >> >> if (...) >> xhci_urb_free_priv(xhci, urb_priv); >> + else >> + kfree(urb_priv); > > Ok, so you're proposing freeing the urb_priv, but leaving the TD > allocated for the Set TR dequeue functions to use? Yes, that looks like > the right solution, feel free to submit a patch. > >> Martin, can you tell if adding these two lines fixes the problem? Hi Alan, yes, the following change has helped. I managed to get twice the "error -71" message (one case is shown here) Jan 16 23:07:56 vostro kernel: usb 3-1.2: Device not responding to set address. Jan 16 23:07:56 vostro kernel: usb 3-1.2: Device not responding to set address. Jan 16 23:07:56 vostro kernel: usb 3-1.2: device not accepting address 17, error -71 Jan 16 23:07:56 vostro kernel: hub 3-1:1.0: unable to enumerate USB device on port 2 but the kmemleak did not report anything after next unplug of the disk anymore. --- linux-3.7.1/drivers/usb/host/xhci-ring.c.ori 2013-01-16 22:51:25.000000000 +0100 +++ linux-3.7.1/drivers/usb/host/xhci-ring.c 2013-01-16 22:53:03.000000000 +0100 @@ -2580,6 +2580,8 @@ (trb_comp_code != COMP_STALL && trb_comp_code != COMP_BABBLE)) xhci_urb_free_priv(xhci, urb_priv); + else + kfree(urb_priv); usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb); if ((urb->actual_length != urb->transfer_buffer_length && Thanks, Martin P.S.: The other kmemleak is still in there but is probably not your business: ;-) # cat /sys/kernel/debug/kmemleak unreferenced object 0xffff88040b60a578 (size 256): comm "swapper/0", pid 1, jiffies 4294937575 (age 688.030s) hex dump (first 32 bytes): 00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N.......... ff ff ff ff ff ff ff ff 38 3f 5d 82 ff ff ff ff ........8?]..... backtrace: [<ffffffff815b1dbd>] kmemleak_alloc+0x21/0x3e [<ffffffff81110536>] slab_post_alloc_hook+0x28/0x2a [<ffffffff81112a6e>] __kmalloc+0xf2/0x104 [<ffffffff81302bd5>] kzalloc.constprop.14+0xe/0x10 [<ffffffff81303036>] device_private_init+0x14/0x63 [<ffffffff81305110>] dev_set_drvdata+0x19/0x2f [<ffffffff815c1ed4>] i801_probe+0x5e/0x451 [<ffffffff81280fb3>] local_pci_probe+0x5b/0xa2 [<ffffffff81282074>] pci_device_probe+0xc8/0xf7 [<ffffffff813056cd>] driver_probe_device+0xa9/0x1c1 [<ffffffff8130583f>] __driver_attach+0x5a/0x7e [<ffffffff81303f7a>] bus_for_each_dev+0x57/0x83 [<ffffffff81305276>] driver_attach+0x19/0x1b [<ffffffff81304e48>] bus_add_driver+0xa8/0x1fa [<ffffffff81305cb1>] driver_register+0x8c/0x106 [<ffffffff81281c6d>] __pci_register_driver+0x5a/0x5e -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html