From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrBMI-0007eS-SC for qemu-devel@nongnu.org; Tue, 27 Oct 2015 17:00:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrBMF-0002Fh-Mu for qemu-devel@nongnu.org; Tue, 27 Oct 2015 17:00:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58790) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrBMF-0002Fd-I6 for qemu-devel@nongnu.org; Tue, 27 Oct 2015 17:00:39 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id EFC2DC0AF7A0 for ; Tue, 27 Oct 2015 21:00:38 +0000 (UTC) Date: Tue, 27 Oct 2015 23:00:36 +0200 From: "Michael S. Tsirkin" Message-ID: <1445979626-10103-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] fixup! virtio: introduce virtio_map List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Igor Mammedov Stefan noticed that we must use memmove, not memcpy, as arguments overlap. Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ed1f274..939f802 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -481,8 +481,8 @@ static void virtqueue_map_iovec(struct iovec *sg, hwaddr *addr, error_report("virtio: memory split makes iovec too large"); exit(1); } - memcpy(sg + i + 1, sg + i, sizeof(*sg) * (*num_sg - i)); - memcpy(addr + i + 1, addr + i, sizeof(*addr) * (*num_sg - i)); + memmove(sg + i + 1, sg + i, sizeof(*sg) * (*num_sg - i)); + memmove(addr + i + 1, addr + i, sizeof(*addr) * (*num_sg - i)); assert(len < sg[i + 1].iov_len); sg[i].iov_len = len; addr[i + 1] += len; -- MST