Module Name: src Committed By: joe Date: Sun Mar 23 18:38:49 UTC 2025
Modified Files: src/sys/dev/pci: if_iavf.c Log Message: avoid NULL pointer dereference on failed memory allocation for sc_ihs To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/if_iavf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_iavf.c diff -u src/sys/dev/pci/if_iavf.c:1.19 src/sys/dev/pci/if_iavf.c:1.20 --- src/sys/dev/pci/if_iavf.c:1.19 Tue Feb 25 02:10:13 2025 +++ src/sys/dev/pci/if_iavf.c Sun Mar 23 18:38:49 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: if_iavf.c,v 1.19 2025/02/25 02:10:13 joe Exp $ */ +/* $NetBSD: if_iavf.c,v 1.20 2025/03/23 18:38:49 joe Exp $ */ /* * Copyright (c) 2013-2015, Intel Corporation @@ -75,7 +75,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_iavf.c,v 1.19 2025/02/25 02:10:13 joe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iavf.c,v 1.20 2025/03/23 18:38:49 joe Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -1870,12 +1870,15 @@ iavf_setup_interrupts(struct iavf_softc fail: if (affinity != NULL) kcpuset_destroy(affinity); - for (vector = 0; vector < num; vector++) { - if (sc->sc_ihs[vector] == NULL) - continue; - pci_intr_disestablish(pa->pa_pc, sc->sc_ihs[vector]); + + if (sc->sc_ihs != NULL) { + for (vector = 0; vector < num; vector++) { + if (sc->sc_ihs[vector] == NULL) + continue; + pci_intr_disestablish(pa->pa_pc, sc->sc_ihs[vector]); + } + kmem_free(sc->sc_ihs, sizeof(sc->sc_ihs[0]) * num); } - kmem_free(sc->sc_ihs, sizeof(sc->sc_ihs[0]) * num); pci_intr_release(pa->pa_pc, sc->sc_ihp, num); return -1;