Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Ensure interrupt handles buffer is zeroed on all...



details:   https://anonhg.NetBSD.org/src/rev/ec084c0cf71a
branches:  trunk
changeset: 938871:ec084c0cf71a
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Thu Sep 17 17:04:31 2020 +0000

description:
Ensure interrupt handles buffer is zeroed on allocation

Prevents crashes trying to deallocate interrupts at shutdown.

Found by kim and mlelstv, confirmed by me

diffstat:

 sys/dev/pci/virtio_pci.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 002a04cd6f49 -r ec084c0cf71a sys/dev/pci/virtio_pci.c
--- a/sys/dev/pci/virtio_pci.c  Thu Sep 17 16:54:31 2020 +0000
+++ b/sys/dev/pci/virtio_pci.c  Thu Sep 17 17:04:31 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.11 2020/05/27 11:24:31 yamaguchi Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.12 2020/09/17 17:04:31 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.11 2020/05/27 11:24:31 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.12 2020/09/17 17:04:31 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -701,7 +701,7 @@
        }
 
        if (pci_intr_type(pc, psc->sc_ihp[0]) == PCI_INTR_TYPE_MSIX) {
-               psc->sc_ihs = kmem_alloc(sizeof(*psc->sc_ihs) * nmsix,
+               psc->sc_ihs = kmem_zalloc(sizeof(*psc->sc_ihs) * nmsix,
                    KM_SLEEP);
 
                error = virtio_pci_setup_msix_interrupts(sc, &psc->sc_pa);
@@ -718,7 +718,7 @@
                psc->sc_ihs_num = nmsix;
                psc->sc_config_offset = VIRTIO_CONFIG_DEVICE_CONFIG_MSI;
        } else if (pci_intr_type(pc, psc->sc_ihp[0]) == PCI_INTR_TYPE_INTX) {
-               psc->sc_ihs = kmem_alloc(sizeof(*psc->sc_ihs) * 1,
+               psc->sc_ihs = kmem_zalloc(sizeof(*psc->sc_ihs) * 1,
                    KM_SLEEP);
 
                error = virtio_pci_setup_intx_interrupt(sc, &psc->sc_pa);



Home | Main Index | Thread Index | Old Index