From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwqEk-0005m1-Cx for qemu-devel@nongnu.org; Tue, 17 Jun 2014 06:03:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwqEf-00041z-L2 for qemu-devel@nongnu.org; Tue, 17 Jun 2014 06:03:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3271) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwqEf-00041S-BW for qemu-devel@nongnu.org; Tue, 17 Jun 2014 06:03:25 -0400 Date: Tue, 17 Jun 2014 12:03:13 +0200 From: Igor Mammedov Message-ID: <20140617120313.09e90c6f@nial.usersys.redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 3/4] memory-backend-file: improve error handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao Cc: Yasunori Goto , "Michael S. Tsirkin" , qemu-devel@nongnu.org, Paolo Bonzini On Mon, 16 Jun 2014 18:05:43 +0800 Hu Tao wrote: > This patch fixes two problems of memory-backend-file: > > 1. If user adds a memory-backend-file object using object_add command, > specifying a non-existing directory for property mem-path, qemu > will core dump with message: > > /nonexistingdir: No such file or directory > Bad ram offset fffffffffffff000 > Aborted (core dumped) > > 2. If user adds a memory-backend-file object using object_add command, > specifying a size that is less than huge page size, qemu > will core dump with message: > > Bad ram offset fffffffffffff000 > Aborted (core dumped) > > Signed-off-by: Hu Tao > --- > exec.c | 26 ++++++++++++++++++-------- > 1 file changed, 18 insertions(+), 8 deletions(-) > > diff --git a/exec.c b/exec.c > index 8705cc5..a6afb4d 100644 > --- a/exec.c > +++ b/exec.c [...] > @@ -1308,7 +1311,14 @@ ram_addr_t qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr, > return -1; > } > > - return ram_block_add(new_block); > + addr = ram_block_add(new_block); > + if (addr == -1) { how this hunk is relevant to commit message? and more important in what case ram_block_add() returns -1? > + g_free(new_block); > + error_setg(errp, "failed to allocate memory\n"); > + return -1; > + } > + > + return addr; > } > #endif >