From: jsg Date: Mon, 22 Nov 2021 14:00:52 +0000 (+0000) Subject: avoid uninitialised variable use in igc(4) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7a97ce60e5846ec420cbeccaad2c20de656ff44e;p=openbsd avoid uninitialised variable use in igc(4) read icr reg before testing bit in result add missing block in rxeof from ix ok kevlo@ patrick@ --- diff --git a/sys/dev/pci/if_igc.c b/sys/dev/pci/if_igc.c index 875a3eb5bd1..e66ca876133 100644 --- a/sys/dev/pci/if_igc.c +++ b/sys/dev/pci/if_igc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_igc.c,v 1.4 2021/10/31 15:25:10 patrick Exp $ */ +/* $OpenBSD: if_igc.c,v 1.5 2021/11/22 14:00:52 jsg Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause * @@ -1283,7 +1283,7 @@ igc_rxeof(struct rx_ring *rxr) uint32_t ptype, staterr = 0; uint16_t len, vtag; uint8_t eop = 0; - int i; + int i, nextp; if (!ISSET(ifp->if_flags, IFF_RUNNING)) return 0; @@ -1342,6 +1342,17 @@ igc_rxeof(struct rx_ring *rxr) if_rxr_inuse(&rxr->rx_ring), rxr->last_desc_filled); } + if (!eop) { + /* + * Figure out the next descriptor of this frame. + */ + nextp = i + 1; + if (nextp == sc->num_rx_desc) + nextp = 0; + nxbuf = &rxr->rx_buffers[nextp]; + /* prefetch(nxbuf); */ + } + mp->m_len = len; m = rxbuf->fmp; @@ -1736,7 +1747,7 @@ int igc_intr_link(void *arg) { struct igc_softc *sc = (struct igc_softc *)arg; - uint32_t reg_icr; + uint32_t reg_icr = IGC_READ_REG(&sc->hw, IGC_ICR); if (reg_icr & IGC_ICR_LSC) { KERNEL_LOCK();