From patchwork Fri Feb 19 13:42:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 8361141 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 D99DF9F2F0 for ; Fri, 19 Feb 2016 13:42:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C3BC2044C for ; Fri, 19 Feb 2016 13:42:53 +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 65F6020494 for ; Fri, 19 Feb 2016 13:42:52 +0000 (UTC) Received: from localhost ([::1]:52385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWlKd-0000C0-RR for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Feb 2016 08:42:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWlKR-0000Ag-JO for qemu-devel@nongnu.org; Fri, 19 Feb 2016 08:42:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWlKN-0004Zo-8k for qemu-devel@nongnu.org; Fri, 19 Feb 2016 08:42:39 -0500 Received: from mail-lf0-x235.google.com ([2a00:1450:4010:c07::235]:36176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWlKN-0004ZV-0i for qemu-devel@nongnu.org; Fri, 19 Feb 2016 08:42:35 -0500 Received: by mail-lf0-x235.google.com with SMTP id 78so53881328lfy.3 for ; Fri, 19 Feb 2016 05:42:34 -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=VlFc5JHtQKD78pI5ZyDQXwL9OGyBbQcPCf05/Twwm4w=; b=gqzHxqLeyZs2n+EF90l+EDGI7P4N+9xM/plQ/d6dRSOgGabEKQ76xdC7RPEX65nYDJ q0yzvbiPcIWM5kY/xL0gSk2pOEybP4ro6y1uTbQYxTCB2zZs5FhiXlq0co6yIewVG5nI P3ebujM5r+NSQ1otOZEy6M3AIxq9kFYX9TbZk= 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=VlFc5JHtQKD78pI5ZyDQXwL9OGyBbQcPCf05/Twwm4w=; b=muCh5rtTZwFJ8xBhaOec3ptH7sABax6eX3Jsaa9v7+e57WlwyT/Dng3Wkv50uDD9Wk sfSwsvD8+WHL1gBW/1ZRXOAGbq+cqM7XuIIVdzYFxsZjKRFcqR3IkcinXgxoRMKT0/sU wQUs9dw/5Vby2ypZj/2jEDRKfT8xOm1CNzKLLlz7+hQT8YHHKWXpRtG0Pr84QPGkUpsc 8OT3azqFLYT9K0PEqidhHfWL70DrpMTQ1PhRXkOEzq+BCg/6vc5xNr+yYB/1+Io6W7iS JQPB5y70n1VYOarCco3VzV5GUsXT0KlRWkfU8yPqId0jX+MNcODWg8K/BeYOxp8JhScn O0dQ== X-Gm-Message-State: AG10YOR5WYckf7Ust4QRQX+0dWp87Y55xgZgP56+lcYYFBxRfOt+m0xmlamIkmba8/ee48zm X-Received: by 10.25.206.135 with SMTP id e129mr5409018lfg.46.1455889354231; Fri, 19 Feb 2016 05:42:34 -0800 (PST) Received: from localhost.localdomain (91-157-175-207.elisa-laajakaista.fi. [91.157.175.207]) by smtp.gmail.com with ESMTPSA id o184sm1557417lfb.15.2016.02.19.05.42.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Feb 2016 05:42:33 -0800 (PST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 19 Feb 2016 15:42:20 +0200 Message-Id: X-Mailer: git-send-email 2.7.0 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::235 Cc: Laurent Vivier Subject: [Qemu-devel] [PULL 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=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 *)); }