From patchwork Thu Aug 11 11:39:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 9275125 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7243260231 for ; Thu, 11 Aug 2016 11:44:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C77228601 for ; Thu, 11 Aug 2016 11:44:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5152828615; Thu, 11 Aug 2016 11:44:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AAE9528601 for ; Thu, 11 Aug 2016 11:44:30 +0000 (UTC) Received: from localhost ([::1]:47769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXoPV-0003Lf-Tj for patchwork-qemu-devel@patchwork.kernel.org; Thu, 11 Aug 2016 07:44:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXoLo-0006j8-7w for qemu-devel@nongnu.org; Thu, 11 Aug 2016 07:40:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXoLm-0001hc-95 for qemu-devel@nongnu.org; Thu, 11 Aug 2016 07:40:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59048) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXoLl-0001hL-SD for qemu-devel@nongnu.org; Thu, 11 Aug 2016 07:40:38 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 65E114E323; Thu, 11 Aug 2016 11:40:37 +0000 (UTC) Received: from localhost (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7BBeZrI021321; Thu, 11 Aug 2016 07:40:36 -0400 From: Amit Shah To: Peter Maydell Date: Thu, 11 Aug 2016 17:09:40 +0530 Message-Id: <0e8b3cdfbc167f4bb7790ef744eaa1ac0e6959f9.1470915381.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 11 Aug 2016 11:40:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2.7 2/4] migration: mmap error check fix X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eyakovlev@virtuozzo.com, Juan Quintela , liang.z.li@intel.com, qemu list , "Dr. David Alan Gilbert" , caoj.fnst@cn.fujitsu.com, Amit Shah , den@openvz.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Evgeny Yakovlev Signed-off-by: Denis V. Lunev Reviewed-by: Amit Shah Reviewed-by: Dr. David Alan Gilbert CC: Juan Quintela CC: Amit Shah Message-Id: <1469785705-16670-1-git-send-email-den@openvz.org> Signed-off-by: Amit Shah --- migration/postcopy-ram.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index abe8c60..9b04778 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; }