xhci: Fix invalid loop check in xhci_free_tt_info()
commit2fa0005575a80b5977f147577b52fe9b91ca9f17
authorTakashi Iwai <tiwai@suse.de>
Fri, 1 Jun 2012 08:06:23 +0000 (1 10:06 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 19 Jun 2012 22:18:25 +0000 (19 23:18 +0100)
treef1b0b60f00f3cdaec8aecc4a138f4d8e8412dfd7
parentf21c193188e8368ea07d867ad4a02596a888f2ca
xhci: Fix invalid loop check in xhci_free_tt_info()

commit 46ed8f00d8982e49f8fe2c1a9cea192f640cb3ba upstream.

xhci_free_tt_info() may access the invalid memory when it removes the
last entry but the list is not empty.  Then tt_next reaches to the
list head but it still tries to check the tt_info of that entry.

This patch fixes the bug and cleans up the messy code by rewriting
with a simple list_for_each_entry_safe().

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