Module Name: src
Committed By: martin
Date: Sun Sep 20 10:14:20 UTC 2020
Modified Files:
src/sys/dev/pci [netbsd-8]: virtio.c
Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1608):
sys/dev/pci/virtio_pci.c: revision 1.12
Ensure interrupt handles buffer is zeroed on allocation
Prevents crashes trying to deallocate interrupts at shutdown.
Found by kim and mlelstv, confirmed by me
To generate a diff of this commit:
cvs rdiff -u -r1.28.2.1 -r1.28.2.2 src/sys/dev/pci/virtio.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/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.28.2.1 src/sys/dev/pci/virtio.c:1.28.2.2
--- src/sys/dev/pci/virtio.c:1.28.2.1 Mon Feb 19 18:19:15 2018
+++ src/sys/dev/pci/virtio.c Sun Sep 20 10:14:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio.c,v 1.28.2.1 2018/02/19 18:19:15 snj Exp $ */
+/* $NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $ */
/*
* Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.1 2018/02/19 18:19:15 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -309,7 +309,7 @@ virtio_setup_interrupts(struct virtio_so
}
if (pci_intr_type(pc, sc->sc_ihp[0]) == PCI_INTR_TYPE_MSIX) {
- sc->sc_ihs = kmem_alloc(sizeof(*sc->sc_ihs) * 2,
+ sc->sc_ihs = kmem_zalloc(sizeof(*sc->sc_ihs) * 2,
KM_SLEEP);
error = virtio_setup_msix_interrupts(sc, &sc->sc_pa);
@@ -326,7 +326,7 @@ virtio_setup_interrupts(struct virtio_so
sc->sc_ihs_num = 2;
sc->sc_config_offset = VIRTIO_CONFIG_DEVICE_CONFIG_MSI;
} else if (pci_intr_type(pc, sc->sc_ihp[0]) == PCI_INTR_TYPE_INTX) {
- sc->sc_ihs = kmem_alloc(sizeof(*sc->sc_ihs) * 1,
+ sc->sc_ihs = kmem_zalloc(sizeof(*sc->sc_ihs) * 1,
KM_SLEEP);
error = virtio_setup_intx_interrupt(sc, &sc->sc_pa);