]> git.baikalelectronics.ru Git - kernel.git/commit
net: ethernet: mlx4: Fix memory allocation in mlx4_buddy_init()
authorShung-Hsi Yu <shung-hsi.yu@suse.com>
Mon, 31 Aug 2020 14:37:09 +0000 (22:37 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 1 Sep 2020 20:13:15 +0000 (13:13 -0700)
commit0dcda0a148d6dd9c7242efbe19befb0f6be22ff0
treebf943962728645f5b67d178819fb3332e8958811
parent401c9bbfde78762c495cfb217fa958a1c9eca3ee
net: ethernet: mlx4: Fix memory allocation in mlx4_buddy_init()

On machines with much memory (> 2 TByte) and log_mtts_per_seg == 0, a
max_order of 31 will be passed to mlx_buddy_init(), which results in
s = BITS_TO_LONGS(1 << 31) becoming a negative value, leading to
kvmalloc_array() failure when it is converted to size_t.

  mlx4_core 0000:b1:00.0: Failed to initialize memory region table, aborting
  mlx4_core: probe of 0000:b1:00.0 failed with error -12

Fix this issue by changing the left shifting operand from a signed literal to
an unsigned one.

Fixes: 19517a24066d ("IB/mlx4: Add a driver Mellanox ConnectX InfiniBand adapters")
Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/mr.c