usb: gadget: f_ecm: Use atomic_t to track in-flight request
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Thu, 9 Jan 2020 13:17:22 +0000 (13:17 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2020 12:33:56 +0000 (04:33 -0800)
commite3ed79d11b2716aaca68ae9afdc79dddae53bdc9
treeb59d24e50a04151bce40039b75e6dfcf963945ee
parentd1e5dcafca963f6c2386ea4f31323f51199a3794
usb: gadget: f_ecm: Use atomic_t to track in-flight request

commit d710562e01c48d59be3f60d58b7a85958b39aeda upstream.

Currently ecm->notify_req is used to flag when a request is in-flight.
ecm->notify_req is set to NULL and when a request completes it is
subsequently reset.

This is fundamentally buggy in that the unbind logic of the ECM driver will
unconditionally free ecm->notify_req leading to a NULL pointer dereference.

Fixes: da741b8c56d6 ("usb ethernet gadget: split CDC Ethernet function")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_ecm.c