[PATCH 3/4] xhci: debugfs: initialize command buffer

From: Jiale Yao

Date: Wed Oct 21 2026 - 06:56:25 EST


xhci_port_write() copies user input into an uninitialized stack buffer
and compares ten bytes against the compliance command. A short matching
prefix can make strncmp() inspect bytes that were not initialized.

Zero-initialize the buffer so the copied input is always terminated.

Fixes: 87a03802184c ("xhci: debugfs: add debugfs interface to enable compliance mode for a port")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/usb/host/xhci-debugfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c
index 2aa01d99f23d..a020cbab9674 100644
--- a/drivers/usb/host/xhci-debugfs.c
+++ b/drivers/usb/host/xhci-debugfs.c
@@ -347,7 +347,7 @@ static ssize_t xhci_port_write(struct file *file, const char __user *ubuf,
struct seq_file *s = file->private_data;
struct xhci_port *port = s->private;
struct xhci_hcd *xhci = hcd_to_xhci(port->rhub->hcd);
- char buf[32];
+ char buf[32] = { };
u32 portsc;
unsigned long flags;

--
2.34.1