From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ww6C2-0006jl-4S for qemu-devel@nongnu.org; Sun, 15 Jun 2014 04:53:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ww6Bx-0001iD-Gn for qemu-devel@nongnu.org; Sun, 15 Jun 2014 04:53:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29643) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ww6Bx-0001i7-8H for qemu-devel@nongnu.org; Sun, 15 Jun 2014 04:53:33 -0400 Date: Sun, 15 Jun 2014 11:53:52 +0300 From: "Michael S. Tsirkin" Message-ID: <20140615085352.GA17822@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH RFC 2/4] check if we have space left for hotplugged memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao Cc: Paolo Bonzini , Igor Mammedov , qemu-devel@nongnu.org, Yasunori Goto On Sat, Jun 14, 2014 at 12:48:57PM +0800, Hu Tao wrote: > If pc-dimm is specified on qemu command line, but only with > -m size (aka not -m size,maxmem,slots) then qemu will core dump. > > This patch fixes the problem. > > Signed-off-by: Hu Tao > --- > hw/mem/pc-dimm.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c > index 8c26568..6e8bf43 100644 > --- a/hw/mem/pc-dimm.c > +++ b/hw/mem/pc-dimm.c > @@ -107,7 +107,12 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, > uint64_t new_addr, ret = 0; > uint64_t address_space_end = address_space_start + address_space_size; > > - assert(address_space_end > address_space_size); > + if (address_space_size == 0) { > + error_setg(errp, "can't add memory beyond 0x%" PRIx64, > + address_space_end); That's quite an unfriendly error message, isn't it? Why not explain what the problem is to the user? > + goto out; > + } > + I would move the assert to this point. It protects against integer overflow. > object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list); > > if (hint) { > -- > 1.9.3