From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqNP1-0002qs-T9 for qemu-devel@nongnu.org; Sun, 25 Oct 2015 11:40:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqNOy-0002WO-K7 for qemu-devel@nongnu.org; Sun, 25 Oct 2015 11:40:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39921) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqNOy-0002Vu-Er for qemu-devel@nongnu.org; Sun, 25 Oct 2015 11:40:08 -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 EB7F3C0AF786 for ; Sun, 25 Oct 2015 15:40:07 +0000 (UTC) Date: Sun, 25 Oct 2015 17:40:05 +0200 From: "Michael S. Tsirkin" Message-ID: <1445787601-5893-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] mmap-alloc: fix error handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini Existing callers are checking for MAP_FAILED, so we should return that on error. Reported-by: Paolo Bonzini Signed-off-by: Michael S. Tsirkin --- util/mmap-alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index 1394269..c37acbe 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -26,7 +26,7 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared) void *ptr1; if (ptr == MAP_FAILED) { - return NULL; + return MAP_FAILED; } /* Make sure align is a power of 2 */ @@ -41,7 +41,7 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared) fd, 0); if (ptr1 == MAP_FAILED) { munmap(ptr, total); - return NULL; + return MAP_FAILED; } ptr += offset; -- MST