From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr98V-0000fq-M1 for qemu-devel@nongnu.org; Tue, 27 Oct 2015 14:38:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zr98U-00048P-T3 for qemu-devel@nongnu.org; Tue, 27 Oct 2015 14:38:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr98U-00047q-Nk for qemu-devel@nongnu.org; Tue, 27 Oct 2015 14:38:18 -0400 Date: Tue, 27 Oct 2015 20:38:15 +0200 From: "Michael S. Tsirkin" Message-ID: <20151027203748-mutt-send-email-mst@redhat.com> References: <1445935663-31971-1-git-send-email-mst@redhat.com> <1445935663-31971-2-git-send-email-mst@redhat.com> <20151027161312.GF5626@stefanha-x1.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151027161312.GF5626@stefanha-x1.localdomain> Subject: Re: [Qemu-devel] [PATCH 1/6] virtio: introduce virtio_map List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Igor Mammedov , qemu-devel@nongnu.org On Tue, Oct 27, 2015 at 04:13:12PM +0000, Stefan Hajnoczi wrote: > On Tue, Oct 27, 2015 at 10:47:56AM +0200, Michael S. Tsirkin wrote: > > + for (i = 0; i < *num_sg; i++) { > > len = sg[i].iov_len; > > sg[i].iov_base = cpu_physical_memory_map(addr[i], &len, is_write); > > - if (sg[i].iov_base == NULL || len != sg[i].iov_len) { > > + if (!sg[i].iov_base) { > > error_report("virtio: error trying to map MMIO memory"); > > exit(1); > > } > > + if (len == sg[i].iov_len) { > > + continue; > > + } > > + if (*num_sg >= max_size) { > > + 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)); > > These should be memmove() since memcpy() arguments are not allowed to overlap. Oh right. Will fix, thanks!