mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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: d1ff70241a ("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>
			
			
This commit is contained in:
		
							parent
							
								
									a90cca7c75
								
							
						
					
					
						commit
						9a03c3d398
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -56,7 +56,7 @@ static bool tb_xdomain_match(const struct tb_cfg_request *req,
 | 
				
			||||||
	case TB_CFG_PKG_XDOMAIN_RESP: {
 | 
						case TB_CFG_PKG_XDOMAIN_RESP: {
 | 
				
			||||||
		const struct tb_xdp_header *res_hdr = pkg->buffer;
 | 
							const struct tb_xdp_header *res_hdr = pkg->buffer;
 | 
				
			||||||
		const struct tb_xdp_header *req_hdr = req->request;
 | 
							const struct tb_xdp_header *req_hdr = req->request;
 | 
				
			||||||
		u8 req_seq, res_seq;
 | 
							u32 req_seq, res_seq;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (pkg->frame.size < req->response_size / 4)
 | 
							if (pkg->frame.size < req->response_size / 4)
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
| 
						 | 
					@ -476,7 +476,7 @@ static void tb_xdp_handle_request(struct work_struct *work)
 | 
				
			||||||
	struct tb_ctl *ctl = tb->ctl;
 | 
						struct tb_ctl *ctl = tb->ctl;
 | 
				
			||||||
	const uuid_t *uuid;
 | 
						const uuid_t *uuid;
 | 
				
			||||||
	int ret = 0;
 | 
						int ret = 0;
 | 
				
			||||||
	u8 sequence;
 | 
						u32 sequence;
 | 
				
			||||||
	u64 route;
 | 
						u64 route;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	route = ((u64)xhdr->route_hi << 32 | xhdr->route_lo) & ~BIT_ULL(63);
 | 
						route = ((u64)xhdr->route_hi << 32 | xhdr->route_lo) & ~BIT_ULL(63);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue