USB: xhci: dbc: fix tty registration race
authorJohan Hovold <johan@kernel.org>
Fri, 8 Oct 2021 09:25:45 +0000 (12:25 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Oct 2021 09:44:59 +0000 (11:44 +0200)
commit0ee66290f00602d91413a3779b0f5ee7e7dd51d9
tree14bfd4c28d4c43c24eb705daf465277a7d42b0fd
parent9f0d6c781cb5ebb03a2ae80d94cfedf2e0d1b4e3
USB: xhci: dbc: fix tty registration race

commit 880de403777376e50bdf60def359fa50a722006f upstream.

Make sure to allocate resources before registering the tty device to
avoid having a racing open() and write() fail to enable rx or
dereference a NULL pointer when accessing the uninitialised fifo.

Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
Cc: stable@vger.kernel.org # 4.16
Cc: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20211008092547.3996295-4-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-dbgtty.c