From patchwork Mon Jul 25 15:03:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 9245885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4DFB0607D3 for ; Mon, 25 Jul 2016 15:05:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 401DD24B48 for ; Mon, 25 Jul 2016 15:05:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3481326223; Mon, 25 Jul 2016 15:05:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 3083B24B48 for ; Mon, 25 Jul 2016 15:05:10 +0000 (UTC) Received: from localhost ([::1]:32859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRhRM-0007Gk-JD for patchwork-qemu-devel@patchwork.kernel.org; Mon, 25 Jul 2016 11:05:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRhQk-0007DQ-J6 for qemu-devel@nongnu.org; Mon, 25 Jul 2016 11:04:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bRhQf-0000uY-Ts for qemu-devel@nongnu.org; Mon, 25 Jul 2016 11:04:29 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:55505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRhQd-0000rH-L2 for qemu-devel@nongnu.org; Mon, 25 Jul 2016 11:04:25 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E611320732; Mon, 25 Jul 2016 11:04:12 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Mon, 25 Jul 2016 11:04:13 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=Scdx5pWn7Ir3M4Ju5OGuAIrmuHA =; b=U7QZGxujIC58jIg02YzuydSw3ldMyCFHXP+w4Z2suYqf5e8lqgXNCZ+Oo+s f2kmJfbs8sxO8kgluDFexski8Cy6ceXRuGdQoV04DVmf0giW5dWOdNtqRl9eR4yD 2yEs5rPVOvgzpFtO2XuD2Qa9mSo3UvQ6R8nAtZ21sR1oV/N8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=Scdx 5pWn7Ir3M4Ju5OGuAIrmuHA=; b=c3ahELR3DK1IpjOB9kK6lsovT5C7DH11aqyC hlc9f2EsKc6uirk6jHKk3uEqXcgHNQUkkH6+Ga4kvirI1l9AsOPRQ2sW4y7UFC0j 2lzhuMPDMn0x7odxs4n/IiJ7OSO/OGujgloxg34IplryOAhdTLOpZHIfT+Qk9Y/t YJIrrdU= X-Sasl-enc: i3wd4kZj247HtLgTmR6OuIEMQyfBl3grzXLrIFdeTnTA 1469459052 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 86A9EF2A1C; Mon, 25 Jul 2016 11:04:12 -0400 (EDT) From: "Emilio G. Cota" To: QEMU Developers Date: Mon, 25 Jul 2016 11:03:43 -0400 Message-Id: <1469459025-23606-2-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1469459025-23606-1-git-send-email-cota@braap.org> References: <1469459025-23606-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.29 Subject: [Qemu-devel] [PATCH 1/3] qdist: fix memory leak during binning X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Paolo Bonzini , Changlong Xie , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In qdist_bin__internal(), to->entries is initialized to a 1-element array, which we then leak when n == from->n. Fix it. Signed-off-by: Emilio G. Cota --- util/qdist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/qdist.c b/util/qdist.c index 56f5738..eb2236c 100644 --- a/util/qdist.c +++ b/util/qdist.c @@ -188,7 +188,7 @@ void qdist_bin__internal(struct qdist *to, const struct qdist *from, size_t n) } } /* they're equally spaced, so copy the dist and bail out */ - to->entries = g_new(struct qdist_entry, from->n); + to->entries = g_realloc_n(to->entries, n, sizeof(*to->entries)); to->n = from->n; memcpy(to->entries, from->entries, sizeof(*to->entries) * to->n); return;