Linux USB
 help / color / mirror / Atom feed
* [PATCH] thunderbolt: debugfs: fix sideband write size check
@ 2026-06-08  6:31 raoxu
  2026-06-08 10:48 ` Mika Westerberg
  0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-06-08  6:31 UTC (permalink / raw)
  To: andreas.noever; +Cc: westeri, YehezkelShB, linux-usb, linux-kernel, raoxu

From: Xu Rao <raoxu@uniontech.com>

sb_regs_write() looks up the matching sideband register entry before
validating the number of bytes to write.

However, the size check uses sb_regs->size, which is the size of the
first entry in the register table, instead of the matched entry. This
rejects valid writes to larger sideband registers such as USB4_SB_DEBUG
or USB4_SB_DATA.

Use the matched register entry for the size check.

Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
 drivers/thunderbolt/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/debugfs.c b/drivers/thunderbolt/debugfs.c
index 25f6ea6ea094..45ec31e2d040 100644
--- a/drivers/thunderbolt/debugfs.c
+++ b/drivers/thunderbolt/debugfs.c
@@ -366,7 +366,7 @@ static ssize_t sb_regs_write(struct tb_port *port, const struct sb_reg *sb_regs,
 		if (!sb_reg)
 			return -EINVAL;
 
-		if (bytes_read > sb_regs->size)
+		if (bytes_read > sb_reg->size)
 			return -E2BIG;
 
 		ret = usb4_port_sb_write(port, target, index, sb_reg->reg, data,
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-08 10:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-08  6:31 [PATCH] thunderbolt: debugfs: fix sideband write size check raoxu
2026-06-08 10:48 ` Mika Westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox