Skip to content

Commit d6dd508

Browse files
keesPaolo Abeni
authored and
Paolo Abeni
committed
bnx2: Use kmalloc_size_roundup() to match ksize() usage
Round up allocations with kmalloc_size_roundup() so that build_skb()'s use of ksize() is always accurate and no special handling of the memory is needed by KASAN, UBSAN_BOUNDS, nor FORTIFY_SOURCE. Cc: Rasesh Mody <[email protected]> Cc: [email protected] Cc: "David S. Miller" <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Paolo Abeni <[email protected]> Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 6459838 commit d6dd508

File tree

1 file changed

+3
-2
lines changed
  • drivers/net/ethernet/broadcom

1 file changed

+3
-2
lines changed

drivers/net/ethernet/broadcom/bnx2.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5415,8 +5415,9 @@ bnx2_set_rx_ring_size(struct bnx2 *bp, u32 size)
54155415

54165416
bp->rx_buf_use_size = rx_size;
54175417
/* hw alignment + build_skb() overhead*/
5418-
bp->rx_buf_size = SKB_DATA_ALIGN(bp->rx_buf_use_size + BNX2_RX_ALIGN) +
5419-
NET_SKB_PAD + SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
5418+
bp->rx_buf_size = kmalloc_size_roundup(
5419+
SKB_DATA_ALIGN(bp->rx_buf_use_size + BNX2_RX_ALIGN) +
5420+
NET_SKB_PAD + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
54205421
bp->rx_jumbo_thresh = rx_size - BNX2_RX_OFFSET;
54215422
bp->rx_ring_size = size;
54225423
bp->rx_max_ring = bnx2_find_max_ring(size, BNX2_MAX_RX_RINGS);

0 commit comments

Comments
 (0)