From patchwork Thu Feb 25 11:01:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 8422491 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EB8049F314 for ; Thu, 25 Feb 2016 11:03:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54200202B8 for ; Thu, 25 Feb 2016 11:03:08 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5BA2D202AE for ; Thu, 25 Feb 2016 11:03:06 +0000 (UTC) Received: from localhost ([::1]:42160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYthJ-0007gI-Q5 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Feb 2016 06:03:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYtfc-00051b-VC for qemu-devel@nongnu.org; Thu, 25 Feb 2016 06:01:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYtfa-0000b2-IZ for qemu-devel@nongnu.org; Thu, 25 Feb 2016 06:01:20 -0500 Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]:34517) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYtfa-0000as-9Q for qemu-devel@nongnu.org; Thu, 25 Feb 2016 06:01:18 -0500 Received: by mail-lf0-x232.google.com with SMTP id j78so30545104lfb.1 for ; Thu, 25 Feb 2016 03:01:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fNaH9t6PsIOevLGfnWREURQ4KPuKsCffEDEsgmEpiUI=; b=J+Eusy+suo/95n82qOerEWOb5H8fVHjl8/6ke2Bxyza1OARHXzteWCg7UMU+NvWZj0 l/Fli30XS6MeuFoQZ18qQW2z/JkrMTcAfCdBKdRnjaZwXS8vbgXPjT/2SeNKUH/Vgzxu ohJeju0lRPznh5rZM3g4hA5WuRTGiNrKtQGH4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fNaH9t6PsIOevLGfnWREURQ4KPuKsCffEDEsgmEpiUI=; b=dKcLs0p4T9+jtPxNXHB4V2MT7uzc19IdB3kYc5LY3SRQvMvjIY7gQTqj4PxP02NPRW 62MUHsudp4h7Uu4pbsoyS7AmMHJPU0eJN6NS5spQ2FstvVQNAmo5afnYxIhp7FuTLDwe BHj5gg0kt465A5Nok40Dc/Wyz1PjJRKcgI79nrVaYLQ8kyVFN4ux46J0KlDivTb7C28X UOImvdop9MJHxbeWcR1Z7f3nqecZAo76MTlHCN+UVubiq8Cx0s7IGep//1ESbmETg0S9 l6dfwgHa9m2UTz2THwNX4oFGf2J25td52FYFLDjUDAaSQtNsXNIYiByWnNxWfYV2osTv 4fQw== X-Gm-Message-State: AG10YOSV0Z+gLFEvfwNRH3LHs/1ASwH5o0WVNtnDAlIio+9EN0nKXgUR1FBXleTJ/1RMhSXt X-Received: by 10.25.156.196 with SMTP id f187mr16575502lfe.150.1456398077425; Thu, 25 Feb 2016 03:01:17 -0800 (PST) Received: from beaming.home (91-157-175-207.elisa-laajakaista.fi. [91.157.175.207]) by smtp.gmail.com with ESMTPSA id f184sm1066803lfe.6.2016.02.25.03.01.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Feb 2016 03:01:16 -0800 (PST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 25 Feb 2016 13:01:06 +0200 Message-Id: <5089c7ce82a49e6a97c5cf3db57a89bca8ed25d8.1456397907.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::232 Cc: Laurent Vivier Subject: [Qemu-devel] [PULL v2 1/8] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Laurent Vivier 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 Signed-off-by: Riku Voipio --- 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 54ce14a..dac5518 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -318,8 +318,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 *)); }