From: mestre Date: Wed, 19 Sep 2018 07:47:54 +0000 (+0000) Subject: In mue_iff() move the initialization of the hash table up so that is done X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bd0c1d2d597c584055fe7f16ad9a25d9aefce702;p=openbsd In mue_iff() move the initialization of the hash table up so that is done unconditionally, like it's done on other devices, so that we don't end up in the situation of the card being put in promiscuous mode or if ac->ac_multirangecnt > 0 and then we would write into the table while being uninitialized a little bit later. Noticed on Coverity ID 1473316. hint from claudio@ and kettenis@ OK kevlo@ claudio@ --- diff --git a/sys/dev/usb/if_mue.c b/sys/dev/usb/if_mue.c index f4d6b9018ba..2f9e3777f6e 100644 --- a/sys/dev/usb/if_mue.c +++ b/sys/dev/usb/if_mue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mue.c,v 1.4 2018/08/15 07:13:51 kevlo Exp $ */ +/* $OpenBSD: if_mue.c,v 1.5 2018/09/19 07:47:54 mestre Exp $ */ /* * Copyright (c) 2018 Kevin Lo @@ -1016,6 +1016,7 @@ mue_iff(struct mue_softc *sc) rxfilt = mue_csr_read(sc, reg); rxfilt &= ~(MUE_RFE_CTL_PERFECT | MUE_RFE_CTL_MULTICAST_HASH | MUE_RFE_CTL_UNICAST | MUE_RFE_CTL_MULTICAST); + memset(hashtbl, 0, sizeof(hashtbl)); ifp->if_flags &= ~IFF_ALLMULTI; /* Always accept broadcast frames. */ @@ -1029,9 +1030,6 @@ mue_iff(struct mue_softc *sc) } else { rxfilt |= MUE_RFE_CTL_PERFECT | MUE_RFE_CTL_MULTICAST_HASH; - /* Clear hash table. */ - memset(hashtbl, 0, sizeof(hashtbl)); - /* Now program new ones. */ ETHER_FIRST_MULTI(step, ac, enm); while (enm != NULL) {