Subject: Coverity: efx_tc_rx(): Memory - illegal accesses

From: coverity-bot <[email-masked]>
Date: Thu, 17 Nov 2022 14:17:15 -0800

Hello!

This is an experimental semi-automated report about issues detected by
Coverity from a scan of next-20221117 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified
lines of code (noted below) that were touched by commits:

  Wed Nov 16 09:07:02 2022 +0000
    25730d8be5d8 ("sfc: add extra RX channel to receive MAE counter updates on ef100")

Coverity reported the following:

*** CID 1527356:  Memory - illegal accesses  (OVERRUN)
drivers/net/ethernet/sfc/tc_counters.c:483 in efx_tc_rx()
477     	}
478
479     	/* Update seen_gen unconditionally, to avoid a missed wakeup if
480     	 * we race with efx_mae_stop_counters().
481     	 */
482     	efx->tc->seen_gen[type] = mark;
vvv     CID 1527356:  Memory - illegal accesses  (OVERRUN)
vvv     Overrunning array "efx->tc->flush_gen" of 3 4-byte elements at element index 3 (byte offset 15) using index "type" (which evaluates to 3).
483     	if (efx->tc->flush_counters &&
484     	    (s32)(efx->tc->flush_gen[type] - mark) <= 0)
485     		wake_up(&efx->tc->flush_wq);
486     out:
487     	efx_free_rx_buffers(rx_queue, rx_buf, 1);
488     	channel->rx_pkt_n_frags = 0;

If this is a false positive, please let us know so we can mark it as
such, or teach the Coverity rules to be smarter. If not, please make
sure fixes get into linux-next. :) For patches fixing this, please
include these lines (but double-check the "Fixes" first):

Reported-by: coverity-bot <[email-masked]>
Addresses-Coverity-ID: 1527356 ("Memory - illegal accesses")
Fixes: 25730d8be5d8 ("sfc: add extra RX channel to receive MAE counter updates on ef100")

AFAICT, efx_tc_rx_version_2() may return EFX_TC_COUNTER_TYPE_MAX.

Thanks for your attention!

-- 
Coverity-bot