From 0036f4b358d892ba33d0d8c17c42e00134477a54 Mon Sep 17 00:00:00 2001 From: nonaka Date: Fri, 6 Dec 2019 12:46:06 +0000 Subject: Clear the allocated memory in hyperv_dma_alloc(). --- sys/dev/hyperv/hyperv_common.c | 8 ++++++-- sys/dev/hyperv/vmbus.c | 6 ++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'sys/dev/hyperv') diff --git a/sys/dev/hyperv/hyperv_common.c b/sys/dev/hyperv/hyperv_common.c index 620865c45b6..bc062c621ab 100644 --- a/sys/dev/hyperv/hyperv_common.c +++ b/sys/dev/hyperv/hyperv_common.c @@ -1,4 +1,4 @@ -/* $NetBSD: hyperv_common.c,v 1.2 2019/05/31 04:23:19 nonaka Exp $ */ +/* $NetBSD: hyperv_common.c,v 1.3 2019/12/06 12:46:06 nonaka Exp $ */ /*- * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.2 2019/05/31 04:23:19 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.3 2019/12/06 12:46:06 nonaka Exp $"); #include "hyperv.h" @@ -155,6 +155,10 @@ hyperv_dma_alloc(bus_dma_tag_t dmat, struct hyperv_dma *dma, bus_size_t size, goto fail4; } + memset(dma->addr, 0, dma->map->dm_mapsize); + bus_dmamap_sync(dmat, dma->map, 0, dma->map->dm_mapsize, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + return dma->addr; fail4: bus_dmamap_destroy(dmat, dma->map); diff --git a/sys/dev/hyperv/vmbus.c b/sys/dev/hyperv/vmbus.c index f6c7cecbe25..d618ad61366 100644 --- a/sys/dev/hyperv/vmbus.c +++ b/sys/dev/hyperv/vmbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: vmbus.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $ */ +/* $NetBSD: vmbus.c,v 1.6 2019/12/06 12:46:06 nonaka Exp $ */ /* $OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.6 2019/12/06 12:46:06 nonaka Exp $"); #include #include @@ -985,7 +985,6 @@ vmbus_channel_alloc(struct vmbus_softc *sc) kmem_free(ch, sizeof(*ch)); return NULL; } - memset(ch->ch_monprm, 0, sizeof(*ch->ch_monprm)); ch->ch_refs = 1; ch->ch_sc = sc; @@ -1264,7 +1263,6 @@ vmbus_channel_ring_create(struct vmbus_channel *ch, uint32_t buflen) "failed to allocate channel ring\n"); return ENOMEM; } - memset(ch->ch_ring, 0, ch->ch_ring_size); memset(&ch->ch_wrd, 0, sizeof(ch->ch_wrd)); ch->ch_wrd.rd_ring = (struct vmbus_bufring *)ch->ch_ring; -- cgit