xhci: Don't free endpoints in xhci_mem_cleanup()
authorTakashi Iwai <tiwai@suse.de>
Fri, 1 Jun 2012 08:06:24 +0000 (10:06 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 19 Jun 2012 22:18:26 +0000 (23:18 +0100)
commita48eb115826dbaaa1b1adab5cc4b763b144d6c7e
tree391d154db5d17fb4f09d071561d320b905acaf4f
parent2fa0005575a80b5977f147577b52fe9b91ca9f17
xhci: Don't free endpoints in xhci_mem_cleanup()

commit 32f1d2c536d0c26c5814cb0e6a0606c42d02fac1 upstream.

This patch fixes a few issues introduced in the recent fix
[f8a9e72d: USB: fix resource leak in xhci power loss path]

- The endpoints listed in bw table are just links and each entry is an
 array member of dev->eps[].  But the commit above adds a kfree() call
 to these instances, and thus it results in memory corruption.

- It clears only the first entry of rh_bw[], but there can be multiple
  ports.

- It'd be safer to clear the list_head of ep as well, not only
  removing from the list, as it's checked in
  xhci_discover_or_reset_device().

This patch should be backported to kernels as old as 3.2, that contain
the commit 839c817ce67178ca3c7c7ad534c571bba1e69ebe "xhci: Store
information about roothubs and TTs."

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Reviewed-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/host/xhci-mem.c