]> git.baikalelectronics.ru Git - kernel.git/commit
USB: yurex: fix NULL-derefs on disconnect
authorJohan Hovold <johan@kernel.org>
Wed, 9 Oct 2019 15:38:48 +0000 (17:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Oct 2019 12:24:06 +0000 (14:24 +0200)
commitaa01d2c779f074ac35649ba6ad5f87c1d2d448de
tree195a9516da77f8fb797ec52fbd278cf3d68e0a72
parentadc4cc712b19b5e5db8c219bda0d0745299f8a52
USB: yurex: fix NULL-derefs on disconnect

The driver was using its struct usb_interface pointer as an inverted
disconnected flag, but was setting it to NULL without making sure all
code paths that used it were done with it.

Before commit ea48ba59e479 ("USB: yurex: Fix protection fault after
device removal") this included the interrupt-in completion handler, but
there are further accesses in dev_err and dev_dbg statements in
yurex_write() and the driver-data destructor (sic!).

Fix this by unconditionally stopping also the control URB at disconnect
and by using a dedicated disconnected flag.

Note that we need to take a reference to the struct usb_interface to
avoid a use-after-free in the destructor whenever the device was
disconnected while the character device was still open.

Fixes: 305ce2dc6d10 ("USB: yurex.c: remove dbg() usage")
Fixes: d3f627d232c0 ("USB: yurex.c: remove err() usage")
Cc: stable <stable@vger.kernel.org> # 3.5: ea48ba59e479
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20191009153848.8664-6-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/misc/yurex.c