UPSTREAM: usb: dwc2: host: Avoid use of chan->qh after qh freed
authorDouglas Anderson <dianders@chromium.org>
Fri, 29 Jan 2016 02:19:55 +0000 (18:19 -0800)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 3 Jan 2017 10:48:08 +0000 (18:48 +0800)
commitc6e98b18a3f49c927c42b293702b830bd8cc1444
treef05027bacd6443640d70b9beb1e2300901e00368
parent3f0d1d69e083419767fc736bba480d72e2464b08
UPSTREAM: usb: dwc2: host: Avoid use of chan->qh after qh freed

When poking around with USB devices with slub_debug enabled, I found
another obvious use after free.  Turns out that in dwc2_hc_n_intr() I
was in a state when the contents of chan->qh was filled with 0x6b,
indicating that chan->qh was freed but chan still had a reference to
it.

Let's make sure that whenever we free qh we also make sure we remove a
reference from its channel.

The bug fixed here doesn't appear to be new--I believe I just got lucky
and happened to see it while stress testing.

Change-Id: I5affca3f0edc051a95c4992ade6b940e07ef3869
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 16e80218816488f016418717d23c660abe073a67)
drivers/usb/dwc2/hcd.c
drivers/usb/dwc2/hcd_intr.c