From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bT5G8-0006oI-2i for qemu-devel@nongnu.org; Fri, 29 Jul 2016 06:43:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bT5G3-0005LA-2G for qemu-devel@nongnu.org; Fri, 29 Jul 2016 06:43:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bT5G2-0005L6-St for qemu-devel@nongnu.org; Fri, 29 Jul 2016 06:43:10 -0400 Date: Fri, 29 Jul 2016 11:43:06 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20160729104306.GC2070@work-vm> References: <1469785705-16670-1-git-send-email-den@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1469785705-16670-1-git-send-email-den@openvz.org> Subject: Re: [Qemu-devel] [PATCH 1/1] migration: mmap error check fix List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: qemu-devel@nongnu.org, Amit Shah , Evgeny Yakovlev , Juan Quintela * Denis V. Lunev (den@openvz.org) wrote: > From: Evgeny Yakovlev > > mmap man page: > "On success, mmap() returns a pointer to the mapped area. On error, the > value MAP_FAILED (that is, (void *) -1) is returned, and errno is set > to indicate the cause of the error." > > The check in postcopy_get_tmp_page is definitely wrong and should be > fixed. Oops, nice spot! Reviewed-by: Dr. David Alan Gilbert > Signed-off-by: Evgeny Yakovlev > Signed-off-by: Denis V. Lunev > CC: Juan Quintela > CC: Amit Shah > --- > migration/postcopy-ram.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c > index abe8c60..e761f3c 100644 > --- a/migration/postcopy-ram.c > +++ b/migration/postcopy-ram.c > @@ -604,7 +604,8 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis) > mis->postcopy_tmp_page = mmap(NULL, getpagesize(), > PROT_READ | PROT_WRITE, MAP_PRIVATE | > MAP_ANONYMOUS, -1, 0); > - if (!mis->postcopy_tmp_page) { > + if (mis->postcopy_tmp_page == MAP_FAILED) { > + mis->postcopy_tmp_page = NULL; > error_report("%s: %s", __func__, strerror(errno)); > return NULL; > } > -- > 2.7.4 > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK