]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thunderbolt: debugfs: Fix sideband write size check
authorXu Rao <raoxu@uniontech.com>
Mon, 8 Jun 2026 06:31:47 +0000 (14:31 +0800)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Mon, 8 Jun 2026 10:47:28 +0000 (12:47 +0200)
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>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/debugfs.c

index 369904287497d6c6d31801524001c6f11b2b4d89..f5cf0e177f400ba2688bcde17125fa61070e6bf8 100644 (file)
@@ -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,