From patchwork Tue Mar 30 08:20:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduard - Gabriel Munteanu X-Patchwork-Id: 89247 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2U8KX1q006137 for ; Tue, 30 Mar 2010 08:20:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755896Ab0C3IUa (ORCPT ); Tue, 30 Mar 2010 04:20:30 -0400 Received: from mail-bw0-f209.google.com ([209.85.218.209]:41750 "EHLO mail-bw0-f209.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755599Ab0C3IU0 (ORCPT ); Tue, 30 Mar 2010 04:20:26 -0400 Received: by bwz1 with SMTP id 1so4153668bwz.21 for ; Tue, 30 Mar 2010 01:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=lKmY5m17++iYsWi2NyQS1DGs0iFrEwtoNvrzkq8+WIM=; b=FqSSl5P8aURBEPCN6aoiJFRCILEzETp1oqFXRufRi7qHuQpN8pKkg3ATvp7V4PHNyq GRQ3THZF9yp+3CzS84wn3u2wYYHZ8mOeyFBAbQ6kzWKHXXQPZsJm6MyeSVhF1jm1QQvz 8c6kR9NrCYd6Zhe6UEt85AUqVmkBhBLXFbt+k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=KMpBdd0DXv32TN+xKrVdYFovpbiixUnytWWokOXjt2DU2SoL2I1UrWVTfioBsJrTrH gFIJD2hH5yWyPtXi9EYbK483cDZEqiZ2UG8DlIsaFrFm1fIYbtzkCAmz58kGMllWaZTT KXpNiTod0LJx35gndWHtEmiAtgdnxmvtgeWQw= Received: by 10.204.140.212 with SMTP id j20mr634590bku.119.1269937223978; Tue, 30 Mar 2010 01:20:23 -0700 (PDT) Received: from localhost.localdomain ([188.25.93.130]) by mx.google.com with ESMTPS id 16sm2589620bwz.9.2010.03.30.01.20.22 (version=SSLv3 cipher=RC4-MD5); Tue, 30 Mar 2010 01:20:23 -0700 (PDT) From: Eduard - Gabriel Munteanu To: joro@8bytes.org Cc: aliguori@us.ibm.com, avi@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, Eduard - Gabriel Munteanu Subject: [RFC PATCH 1/7] acpi: qemu_realloc() might return a different pointer Date: Tue, 30 Mar 2010 11:20:02 +0300 Message-Id: <9b87085a250d0f70509687e4ab09336244734fad.1269936879.git.eduard.munteanu@linux360.ro> X-Mailer: git-send-email 1.6.4.4 In-Reply-To: References: Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 30 Mar 2010 08:20:34 +0000 (UTC) diff --git a/hw/acpi.c b/hw/acpi.c index d293127..7c4e8d3 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -857,7 +857,7 @@ int acpi_table_add(const char *t) char buf[1024], *p, *f; struct acpi_table_header acpi_hdr; unsigned long val; - size_t off; + size_t newlen, off; memset(&acpi_hdr, 0, sizeof(acpi_hdr)); @@ -938,9 +938,10 @@ int acpi_table_add(const char *t) acpi_tables_len = sizeof(uint16_t); acpi_tables = qemu_mallocz(acpi_tables_len); } + newlen = acpi_tables_len + sizeof(uint16_t) + acpi_hdr.length; + acpi_tables = qemu_realloc(acpi_tables, newlen); p = acpi_tables + acpi_tables_len; - acpi_tables_len += sizeof(uint16_t) + acpi_hdr.length; - acpi_tables = qemu_realloc(acpi_tables, acpi_tables_len); + acpi_tables_len = newlen; acpi_hdr.length = cpu_to_le32(acpi_hdr.length); *(uint16_t*)p = acpi_hdr.length;