Skip to content

Commit 8909961

Browse files
committed
MFC r350630, r350657: static analysis fixes from Haiku
r350630: oce(4): potential out of bounds access before vector validation r350657: ral: rt2860: fix wcid2ni access/size issue RT2860_WCID_MAX is supposed to describe the max STA index for wcid2ni, and was instead being used as the size -- off-by-one. rt2860_drain_stats_fifo was range-checking wcid only after accessing out-of-bounds potentially.
1 parent c42ab65 commit 8909961

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

sys/dev/oce/oce_if.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,12 +836,14 @@ oce_fast_isr(void *arg)
836836
static int
837837
oce_alloc_intr(POCE_SOFTC sc, int vector, void (*isr) (void *arg, int pending))
838838
{
839-
POCE_INTR_INFO ii = &sc->intrs[vector];
839+
POCE_INTR_INFO ii;
840840
int rc = 0, rr;
841841

842842
if (vector >= OCE_MAX_EQ)
843843
return (EINVAL);
844844

845+
ii = &sc->intrs[vector];
846+
845847
/* Set the resource id for the interrupt.
846848
* MSIx is vector + 1 for the resource id,
847849
* INTx is 0 for the resource id.

sys/dev/ral/rt2860.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,10 +1092,12 @@ rt2860_drain_stats_fifo(struct rt2860_softc *sc)
10921092
DPRINTFN(4, ("tx stat 0x%08x\n", stat));
10931093

10941094
wcid = (stat >> RT2860_TXQ_WCID_SHIFT) & 0xff;
1095+
if (wcid > RT2860_WCID_MAX)
1096+
continue;
10951097
ni = sc->wcid2ni[wcid];
10961098

10971099
/* if no ACK was requested, no feedback is available */
1098-
if (!(stat & RT2860_TXQ_ACKREQ) || wcid == 0xff || ni == NULL)
1100+
if (!(stat & RT2860_TXQ_ACKREQ) || ni == NULL)
10991101
continue;
11001102

11011103
/* update per-STA AMRR stats */

sys/dev/ral/rt2860var.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ struct rt2860_softc {
142142
#define RT2860_PCIE (1 << 2)
143143
#define RT2860_RUNNING (1 << 3)
144144

145-
struct ieee80211_node *wcid2ni[RT2860_WCID_MAX];
145+
struct ieee80211_node *wcid2ni[RT2860_WCID_MAX + 1];
146146

147147
struct rt2860_tx_ring txq[6];
148148
struct rt2860_rx_ring rxq;

0 commit comments

Comments
 (0)