Print this page
MFV: illumos-gate@9f16e2df28efab26216cf68e3841c0a460c5bb73
9790 buffer freed to wrong cache in virtio_register_intx
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Reviewed by: Andy Fiddaman <omnios@citrus-it.net>
Approved by: Garrett D'Amore <garrett@damore.org>
Author: Hans Rosenfeld <hans.rosenfeld@joyent.com>
re #13879 make libsqlite a real shared lib (tweaks)
  Fix rebuild after pull (remove files left in the way)
  Make sqlite.h SQLITE_VERSION more predictable.
OS-5 Integrate virtio drivers
    integration cleanup (copyrights, cddl 1.0)
port of illumos-3644
    3644 Add virtio-net support into the Illumos
    Reviewed by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
    Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
    Reviewed by: David Hoppner <0xffea@gmail.com>
port of illumos-1562
    1562 Integrate the virtio core module
    Reviewed by: Dmitry Yusupov <Dmitry.Yusupov@nexenta.com>
    Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
    Approved by: Garrett D'Amore <garrett@damore.org>
        
*** 1,30 ****
  /*
!  * CDDL HEADER START
   *
!  * The contents of this file are subject to the terms of the
!  * Common Development and Distribution License (the "License").
!  * You may not use this file except in compliance with the License.
!  *
!  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
!  * or http://www.opensolaris.org/os/licensing.
!  * See the License for the specific language governing permissions
!  * and limitations under the License.
!  *
!  * When distributing Covered Code, include this CDDL HEADER in each
!  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
!  * If applicable, add the following below this CDDL HEADER, with the
!  * fields enclosed by brackets "[]" replaced with your own identifying
!  * information: Portions Copyright [yyyy] [name of copyright owner]
!  *
!  * CDDL HEADER END
   */
  
  /*
   * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
   * Copyright 2012 Alexey Zaytsev <alexey.zaytsev@gmail.com>
   * Copyright (c) 2016 by Delphix. All rights reserved.
   */
  
  /* Based on the NetBSD virtio driver by Minoura Makoto. */
  /*
   * Copyright (c) 2010 Minoura Makoto.
--- 1,21 ----
  /*
!  * This file and its contents are supplied under the terms of the
!  * Common Development and Distribution License ("CDDL"), version 1.0.
!  * You may only use this file in accordance with the terms of version
!  * 1.0 of the CDDL.
   *
!  * A full copy of the text of the CDDL should have accompanied this
!  * source.  A copy of the CDDL is also available via the Internet at
!  * http://www.illumos.org/license/CDDL.
   */
  
  /*
   * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
   * Copyright 2012 Alexey Zaytsev <alexey.zaytsev@gmail.com>
   * Copyright (c) 2016 by Delphix. All rights reserved.
+  * Copyright 2017 Joyent, Inc.
   */
  
  /* Based on the NetBSD virtio driver by Minoura Makoto. */
  /*
   * Copyright (c) 2010 Minoura Makoto.
*** 982,1008 ****
  virtio_register_intx(struct virtio_softc *sc,
      struct virtio_int_handler *config_handler,
      struct virtio_int_handler vq_handlers[])
  {
          int vq_handler_count;
-         int config_handler_count = 0;
          int actual;
          struct virtio_handler_container *vhc;
          int ret = DDI_FAILURE;
  
          /* Walk the handler table to get the number of handlers. */
          for (vq_handler_count = 0;
              vq_handlers && vq_handlers[vq_handler_count].vh_func;
              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->nhandlers = vq_handler_count;
          (void) memcpy(vhc->vq_handlers, vq_handlers,
              sizeof (struct virtio_int_handler) * vq_handler_count);
  
          if (config_handler != NULL) {
--- 973,997 ----
  virtio_register_intx(struct virtio_softc *sc,
      struct virtio_int_handler *config_handler,
      struct virtio_int_handler vq_handlers[])
  {
          int vq_handler_count;
          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. */
          for (vq_handler_count = 0;
              vq_handlers && vq_handlers[vq_handler_count].vh_func;
              vq_handler_count++)
                  ;
  
!         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,
              sizeof (struct virtio_int_handler) * vq_handler_count);
  
          if (config_handler != NULL) {
*** 1044,1055 ****
  out_add_handlers:
  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));
          return (ret);
  }
  
  /*
   * We find out if we support MSI during this, and the register layout
--- 1033,1043 ----
  out_add_handlers:
  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, vhc_sz);
          return (ret);
  }
  
  /*
   * We find out if we support MSI during this, and the register layout