mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-23 19:11:51 +00:00
net/mlx4: Fix UBSAN warning of signed integer overflow
[ Upstream commita463146e67
] UBSAN: Undefined behavior in drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:626:29 signed integer overflow: 1802201963 + 1802201963 cannot be represented in type 'int' The union of res_reserved and res_port_rsvd[MLX4_MAX_PORTS] monitors granting of reserved resources. The grant operation is calculated and protected, thus both members of the union cannot be negative. Changed type of res_reserved and of res_port_rsvd[MLX4_MAX_PORTS] from signed int to unsigned int, allowing large value. Fixes:5a0d0a6161
("mlx4: Structures and init/teardown for VF resource quotas") Signed-off-by: Aya Levin <ayal@mellanox.com> Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
034f7ad3f7
commit
b53fa368dd
1 changed files with 2 additions and 2 deletions
|
@ -540,8 +540,8 @@ struct slave_list {
|
|||
struct resource_allocator {
|
||||
spinlock_t alloc_lock; /* protect quotas */
|
||||
union {
|
||||
int res_reserved;
|
||||
int res_port_rsvd[MLX4_MAX_PORTS];
|
||||
unsigned int res_reserved;
|
||||
unsigned int res_port_rsvd[MLX4_MAX_PORTS];
|
||||
};
|
||||
union {
|
||||
int res_free;
|
||||
|
|
Loading…
Reference in a new issue