From c065fca54cda14d0007fb25773dde99a599627ce Mon Sep 17 00:00:00 2001 From: stsp Date: Tue, 8 Feb 2022 14:24:36 +0000 Subject: [PATCH] Fix a KASSERT in iwm(4) being triggered for the wrong reason. iwm_wakeup() must initialize the task reference counter only if resuming the device succeeds. Otherwise, the newstate task will not be scheduled and hence the ref counter must remain at zero. Problem observed by + ok kettenis@ --- sys/dev/pci/if_iwm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index 5e0af5f824d..26d48bf5b80 100644 --- a/sys/dev/pci/if_iwm.c +++ b/sys/dev/pci/if_iwm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwm.c,v 1.390 2022/01/21 15:51:02 stsp Exp $ */ +/* $OpenBSD: if_iwm.c,v 1.391 2022/02/08 14:24:36 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -11719,8 +11719,6 @@ iwm_wakeup(struct iwm_softc *sc) struct ifnet *ifp = &sc->sc_ic.ic_if; int err; - refcnt_init(&sc->task_refs); - err = iwm_start_hw(sc); if (err) return err; @@ -11729,6 +11727,7 @@ iwm_wakeup(struct iwm_softc *sc) if (err) return err; + refcnt_init(&sc->task_refs); ifq_clr_oactive(&ifp->if_snd); ifp->if_flags |= IFF_RUNNING; -- 2.20.1