Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bnxt_en: Fix allocation of zero statistics block size regression.

Recent commit added logic to determine the appropriate statistics block
size to allocate and the size is stored in bp->hw_ring_stats_size. But
if the firmware spec is older than 1.6.0, it is 0 and not initialized.
This causes the allocation to fail with size 0 and bnxt_open() to
abort. Fix it by always initializing bp->hw_ring_stats_size to the
legacy default size value.

Fixes: 4e7485066373 ("bnxt_en: Allocate the larger per-ring statistics block for 57500 chips.")
Reported-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Tested-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Michael Chan and committed by
David S. Miller
fbbdbc64 dd016aca

+1 -2
+1 -2
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 4985 4985 struct hwrm_vnic_qcaps_input req = {0}; 4986 4986 int rc; 4987 4987 4988 + bp->hw_ring_stats_size = sizeof(struct ctx_hw_stats); 4988 4989 if (bp->hwrm_spec_code < 0x10600) 4989 4990 return 0; 4990 4991 ··· 5005 5004 if (bp->max_tpa_v2) 5006 5005 bp->hw_ring_stats_size = 5007 5006 sizeof(struct ctx_hw_stats_ext); 5008 - else 5009 - bp->hw_ring_stats_size = sizeof(struct ctx_hw_stats); 5010 5007 } 5011 5008 mutex_unlock(&bp->hwrm_cmd_lock); 5012 5009 return rc;