vmxnet3: make descriptor count checks more robust

When we update credits there is a potential for a race causing an
overflow of vxcr_next (i.e. incrementing it past vxcr_ndesc). Change the
check to >= rather than == to be more robust against this.

Reviewed by:	emaste
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43712
This commit is contained in:
Kristof Provost 2024-06-10 10:47:38 +02:00
parent e5a54f19be
commit 3ff0dc1af8

View File

@ -1429,7 +1429,8 @@ vmxnet3_isc_txd_credits_update(void *vsc, uint16_t txqid, bool clear)
return (1);
vmxnet3_barrier(sc, VMXNET3_BARRIER_RD);
if (++txc->vxcr_next == txc->vxcr_ndesc) {
MPASS(txc->vxcr_next < txc->vxcr_ndesc);
if (++txc->vxcr_next >= txc->vxcr_ndesc) {
txc->vxcr_next = 0;
txc->vxcr_gen ^= 1;
}