Skip to content

Commit 43635ff

Browse files
lucasdemarchigregkh
authored andcommitted
xhci: dbgtty: Fix unregister on tty_register_driver() failure
commit a916fa6 upstream. If tty_register_driver() fails, it drops the reference, but fails to set the global dbc_tty_driver to NULL, causing the unregister to be called again when module exits. On module unload dbc_tty_exit() only gates its cleanup on the driver pointer being non-NULL, so it operates on the already-freed driver: module_init(xhci_hcd_init) xhci_hcd_init() xhci_dbc_init() [return value ignored] dbc_tty_init() tty_register_driver() fails tty_driver_kref_put() -> driver freed (dbc_tty_driver left dangling) ... module_exit(xhci_hcd_fini) xhci_hcd_fini() xhci_dbc_exit() dbc_tty_exit() if (dbc_tty_driver) -> true (dangling) tty_unregister_driver() -> use-after-free Fixes: 4521f16 ("xhci: dbctty: split dbc tty driver registration and unregistration functions.") Cc: stable@vger.kernel.org # v5.10 Cc: Mathias Nyman <mathias.nyman@linux.intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Lucas De Marchi <ldemarchi@nvidia.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20260806142113.2436238-8-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9790f6e commit 43635ff

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

drivers/usb/host/xhci-dbgtty.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ int dbc_tty_init(void)
620620
pr_err("Can't register dbc tty driver\n");
621621
tty_driver_kref_put(dbc_tty_driver);
622622
idr_destroy(&dbc_tty_minors);
623+
dbc_tty_driver = NULL;
623624
}
624625

625626
return ret;

0 commit comments

Comments
 (0)