From patchwork Mon Jan 18 22:50:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 569689 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F34BE140C10 for ; Tue, 19 Jan 2016 09:51:21 +1100 (AEDT) Received: from localhost ([::1]:34115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLIdr-0004vA-MG for incoming@patchwork.ozlabs.org; Mon, 18 Jan 2016 17:51:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLIdZ-0004UR-QY for qemu-devel@nongnu.org; Mon, 18 Jan 2016 17:51:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLIdW-0005JX-Ll for qemu-devel@nongnu.org; Mon, 18 Jan 2016 17:51:01 -0500 Received: from smtp1-g21.free.fr ([212.27.42.1]:3369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLIdW-0005JN-Fx for qemu-devel@nongnu.org; Mon, 18 Jan 2016 17:50:58 -0500 Received: from Quad.localdomain (unknown [IPv6:2a01:e34:eeee:5240:12c3:7bff:fe6b:9a76]) by smtp1-g21.free.fr (Postfix) with ESMTPS id 24EE794007A; Mon, 18 Jan 2016 23:49:34 +0100 (CET) From: Laurent Vivier To: Riku Voipio Date: Mon, 18 Jan 2016 23:50:45 +0100 Message-Id: <1453157445-1433-1-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.5.0 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.1 Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, Laurent Vivier Subject: [Qemu-devel] [PATCH] linux-user: fix realloc size of target_fd_trans. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org target_fd_trans is an array of "TargetFdTrans *": compute size accordingly. Use g_renew() as proposed by Paolo. Reported-by: Paolo Bonzini Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0cbace4..fd04e5f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -330,8 +330,8 @@ static void fd_trans_register(int fd, TargetFdTrans *trans) if (fd >= target_fd_max) { oldmax = target_fd_max; target_fd_max = ((fd >> 6) + 1) << 6; /* by slice of 64 entries */ - target_fd_trans = g_realloc(target_fd_trans, - target_fd_max * sizeof(TargetFdTrans)); + target_fd_trans = g_renew(TargetFdTrans *, + target_fd_trans, target_fd_max); memset((void *)(target_fd_trans + oldmax), 0, (target_fd_max - oldmax) * sizeof(TargetFdTrans *)); }