From 9f16e2df28efab26216cf68e3841c0a460c5bb73 Mon Sep 17 00:00:00 2001 From: Hans Rosenfeld Date: Mon, 9 Oct 2017 13:19:27 +0200 Subject: [PATCH] 9790 buffer freed to wrong cache in virtio_register_intx Reviewed by: Robert Mustacchi Reviewed by: Patrick Mooney Reviewed by: Yuri Pankov Reviewed by: Andy Fiddaman Approved by: Garrett D'Amore --- usr/src/uts/common/io/virtio/virtio.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/usr/src/uts/common/io/virtio/virtio.c b/usr/src/uts/common/io/virtio/virtio.c index adcd14f2b5..19a66b8f38 100644 --- a/usr/src/uts/common/io/virtio/virtio.c +++ b/usr/src/uts/common/io/virtio/virtio.c @@ -23,6 +23,7 @@ * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright 2012 Alexey Zaytsev * Copyright (c) 2016 by Delphix. All rights reserved. + * Copyright 2017 Joyent, Inc. */ /* Based on the NetBSD virtio driver by Minoura Makoto. */ @@ -984,9 +985,9 @@ virtio_register_intx(struct virtio_softc *sc, struct virtio_int_handler vq_handlers[]) { int vq_handler_count; - int config_handler_count = 0; int actual; struct virtio_handler_container *vhc; + size_t vhc_sz; int ret = DDI_FAILURE; /* Walk the handler table to get the number of handlers. */ @@ -995,11 +996,9 @@ virtio_register_intx(struct virtio_softc *sc, vq_handler_count++) ; - if (config_handler != NULL) - config_handler_count = 1; - - vhc = kmem_zalloc(sizeof (struct virtio_handler_container) + - sizeof (struct virtio_int_handler) * vq_handler_count, KM_SLEEP); + vhc_sz = sizeof (struct virtio_handler_container) + + sizeof (struct virtio_int_handler) * vq_handler_count; + vhc = kmem_zalloc(vhc_sz, KM_SLEEP); vhc->nhandlers = vq_handler_count; (void) memcpy(vhc->vq_handlers, vq_handlers, @@ -1046,8 +1045,7 @@ out_prio: (void) ddi_intr_free(sc->sc_intr_htable[0]); out_int_alloc: kmem_free(sc->sc_intr_htable, sizeof (ddi_intr_handle_t)); - kmem_free(vhc, sizeof (struct virtio_int_handler) * - (vq_handler_count + config_handler_count)); + kmem_free(vhc, vhc_sz); return (ret); } -- 2.11.4.GIT