]> git.baikalelectronics.ru Git - kernel.git/commit
thunderbolt: Fix a couple right shifting to zero bugs
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 17 Oct 2017 12:32:17 +0000 (15:32 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 Oct 2017 12:04:32 +0000 (13:04 +0100)
commit86fd38ad126329f05d3a23a3aa56ada8999e8dfd
tree2091433de0df2d70996ed29f4063a0ad52f1b61a
parent8d615ab10c6d05fa85aaf9cbc4cdc482513dcbc5
thunderbolt: Fix a couple right shifting to zero bugs

The problematic code looks like this:

res_seq = res_hdr->xd_hdr.length_sn & TB_XDOMAIN_SN_MASK;
res_seq >>= TB_XDOMAIN_SN_SHIFT;

TB_XDOMAIN_SN_SHIFT is 27, and right shifting a u8 27 bits is always
going to result in zero.  The fix is to declare these variables as u32.

Fixes: 3a945a67fa06 ("thunderbolt: Add support for XDomain discovery protocol")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/thunderbolt/xdomain.c