FAILED: patch "[PATCH] xhci: dbgtty: Fix unregister on tty_register_driver() failure" failed to apply to 5.10-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x a916fa66a43e10f63198b6ce978badffc678821a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026083142-everyday-fifteen-2ae3@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From a916fa66a43e10f63198b6ce978badffc678821a Mon Sep 17 00:00:00 2001
From: Lucas De Marchi <[email protected]>
Date: Thu, 6 Aug 2026 17:21:03 +0300
Subject: [PATCH] xhci: dbgtty: Fix unregister on tty_register_driver() failure
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-freedrivers/usb/host/xhci-dbgtty.c +1 -0
@@ -651,6 +651,7 @@ int dbc_tty_init(void)pr_err ("Can't register dbc tty driver\n" );tty_driver_kref_put (dbc_tty_driver);idr_destroy (&dbc_tty_minors); + dbc_tty_driver =NULL ; }return ret;
Sasha Levin
maintainerPATCH 1/5 tty: make tty_set_operations an inline
From: Jiri Slaby <[email protected]>
[ Upstream commit cb9ea618ee60313d9278b2ba75f56da2531c8cac ]
Since commit f34d7a5b7010 (tty: The big operations rework) in 2008, tty_set_operations() is a simple one-line assignment. There is no reason for this to be an exported function, hence move it to a header and make an inline from that.
Stable-dep-of: a916fa66a43e ("xhci: dbgtty: Fix unregister on tty_register_driver() failure")
--- drivers/tty/tty_io.c | 7 ------- include/linux/tty_driver.h | 8 ++++++-- 2 files changed, 6 insertions(+), 9 deletions(-)
drivers/tty/tty_io.c +0 -7
@@ -3393,13 +3393,6 @@ void tty_driver_kref_put(struct tty_driver *driver) }EXPORT_SYMBOL (tty_driver_kref_put); -void tty_set_operations (struct tty_driver *driver, -const struct tty_operations *op) -{ - driver->ops = op; -}; -EXPORT_SYMBOL (tty_set_operations); -void put_tty_driver (struct tty_driver *d) {tty_driver_kref_put (d);
include/linux/tty_driver.h +6 -2
@@ -329,8 +329,6 @@ extern struct list_head tty_drivers;extern struct tty_driver *__tty_alloc_driver (unsigned int lines,struct module *owner,unsigned long flags);extern void put_tty_driver (struct tty_driver *driver); -extern void tty_set_operations (struct tty_driver *driver, -const struct tty_operations *op);extern struct tty_driver *tty_find_polling_driver (char *name,int *line);extern void tty_driver_kref_put (struct tty_driver *driver);
@@ -357,6 +355,12 @@ static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)return d; } +static inline void tty_set_operations (struct tty_driver *driver, +const struct tty_operations *op) +{ + driver->ops = op; +} +/* tty driver magic number */ #define TTY_DRIVER_MAGIC 0x5402
Signature · 1 line
2.53.0