Skip to content

Commit f153546

Browse files
mfijalkoanguy11
authored andcommitted
ice: fix NULL pointer dereference in ice_update_vsi_tx_ring_stats()
It is possible to do NULL pointer dereference in routine that updates Tx ring stats. Currently only stats and bytes are updated when ring pointer is valid, but later on ring is accessed to propagate gathered Tx stats onto VSI stats. Change the existing logic to move to next ring when ring is NULL. Fixes: e72bba2 ("ice: split ice_ring onto Tx/Rx separate structs") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Acked-by: Alexander Lobakin <alexandr.lobakin@intel.com> Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent e9c14b5 commit f153546

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5962,8 +5962,9 @@ ice_update_vsi_tx_ring_stats(struct ice_vsi *vsi,
59625962
u64 pkts = 0, bytes = 0;
59635963

59645964
ring = READ_ONCE(rings[i]);
5965-
if (ring)
5966-
ice_fetch_u64_stats_per_ring(&ring->syncp, ring->stats, &pkts, &bytes);
5965+
if (!ring)
5966+
continue;
5967+
ice_fetch_u64_stats_per_ring(&ring->syncp, ring->stats, &pkts, &bytes);
59675968
vsi_stats->tx_packets += pkts;
59685969
vsi_stats->tx_bytes += bytes;
59695970
vsi->tx_restart += ring->tx_stats.restart_q;

0 commit comments

Comments
 (0)