Permalink
Browse files

virtio: Fix an allocation in virtio_register_intx

  • Loading branch information...
1 parent b37c52b commit 0c1269de05f1b5f860df4aa4d1a10e4273c12a5c @xl0 committed Aug 21, 2011
Showing with 3 additions and 5 deletions.
  1. +3 −5 virtio/virtio.c
View
@@ -1031,8 +1031,9 @@ virtio_register_intx(struct virtio_softc *sc,
if (config_handler)
config_handler_count = 1;
- vhc = kmem_alloc(sizeof (struct virtio_int_handler) *
- (vq_handler_count + config_handler_count), KM_SLEEP);
+ vhc = kmem_zalloc(sizeof (struct virtio_handler_container) +
+ sizeof (struct virtio_int_handler) * vq_handler_count,
+ KM_SLEEP);
if (!vhc) {
dev_err(sc->sc_dev, CE_WARN, "Failed to allocate memory "
"for the handler container");
@@ -1046,9 +1047,6 @@ virtio_register_intx(struct virtio_softc *sc,
if (config_handler) {
(void) memcpy(&vhc->config_handler, config_handler,
sizeof (struct virtio_int_handler));
- } else {
- memset(&vhc->config_handler, 0,
- sizeof(struct virtio_int_handler));
}
sc->sc_intr_htable = kmem_zalloc(sizeof (ddi_intr_handle_t), KM_SLEEP);

0 comments on commit 0c1269d

Please sign in to comment.