summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2021-09-08 13:06:54 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2021-09-08 13:06:54 +0000
commitb8db54bf6a0875293344ee68e9c6963830c6e915 (patch)
tree0e63730d844591ab532e3e7b706ac023468fe2e9 /sys/dev
parent5504f3b389642bd2c0e3212b2b23277a28836812 (diff)
Add a missing call to iwx_ctxt_info_free_fw_img() in an error path
of iwx_ctxt_info_init() which should always free on error. Also, free firmware paging DMA memory in case loading firmware has failed. If we don't free paging on error we hit KASSERT(dram->paging == NULL) in iwx_init_fw_sec() once we try to load firmware again. I have hit this while debugging firmware load failures during suspend/resume. ok mpi@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_iwx.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/dev/pci/if_iwx.c b/sys/dev/pci/if_iwx.c
index 1ce02ab5377..97e9bb4f504 100644
--- a/sys/dev/pci/if_iwx.c
+++ b/sys/dev/pci/if_iwx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwx.c,v 1.105 2021/09/08 13:06:23 stsp Exp $ */
+/* $OpenBSD: if_iwx.c,v 1.106 2021/09/08 13:06:53 stsp Exp $ */
/*
* Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
@@ -914,8 +914,10 @@ iwx_ctxt_info_init(struct iwx_softc *sc, const struct iwx_fw_sects *fws)
IWX_WRITE(sc, IWX_CSR_CTXT_INFO_BA + 4, paddr >> 32);
/* kick FW self load */
- if (!iwx_nic_lock(sc))
+ if (!iwx_nic_lock(sc)) {
+ iwx_ctxt_info_free_fw_img(sc);
return EBUSY;
+ }
iwx_write_prph(sc, IWX_UREG_CPU_INIT_RUN, 1);
iwx_nic_unlock(sc);
@@ -3364,8 +3366,10 @@ iwx_load_firmware(struct iwx_softc *sc)
/* wait for the firmware to load */
err = tsleep_nsec(&sc->sc_uc, 0, "iwxuc", SEC_TO_NSEC(1));
- if (err || !sc->sc_uc.uc_ok)
+ if (err || !sc->sc_uc.uc_ok) {
printf("%s: could not load firmware, %d\n", DEVNAME(sc), err);
+ iwx_ctxt_info_free_paging(sc);
+ }
iwx_ctxt_info_free_fw_img(sc);