From patchwork Thu Jan 2 22:06:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 234719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6BF5C3276C for ; Thu, 2 Jan 2020 22:30:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C4162464B for ; Thu, 2 Jan 2020 22:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004210; bh=vorHKAAlo2Q/D/7oNeovywhUHPTU36ycKOYuHV/ww9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PZQtnzaFdjK5dK400jIBdLFj6rX37Ec25rYIrJZzdhkEdkz3MFqK3wro0fgNMF+ze uEqkW6+XpniGtI6Tm/U6C7+t0DYfZv2AK+pA0nv07n5z9gCvOTFp6EnoLB1pImC/Xb 8LrPLnOkmlgZbB1Lc16OT0YSnb6gREGcotMTDjdY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730132AbgABWaJ (ORCPT ); Thu, 2 Jan 2020 17:30:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:33530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729980AbgABWaI (ORCPT ); Thu, 2 Jan 2020 17:30:08 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4A8D720863; Thu, 2 Jan 2020 22:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004207; bh=vorHKAAlo2Q/D/7oNeovywhUHPTU36ycKOYuHV/ww9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fyaT7/0xbB20FG1UOJpwStTTbNIPLgnsuWopyOsYctakXF0rtXU+m5WSRvkRScVvV Lfc5K4I58L/cRRR6VbxVp7F5wzEyupvht52mvgTdWRLqqtlc8buG40DmL8Lyi3pf70 pn+Ksrzdwhvos7rHS/gYCexzcwXWW3utcjXFYGJU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hewenliang , "Steven Rostedt (VMware)" , Tzvetomir Stoyanov , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.9 083/171] libtraceevent: Fix memory leakage in copy_filter_type Date: Thu, 2 Jan 2020 23:06:54 +0100 Message-Id: <20200102220558.483963336@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.960200039@linuxfoundation.org> References: <20200102220546.960200039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Hewenliang [ Upstream commit 10992af6bf46a2048ad964985a5b77464e5563b1 ] It is necessary to free the memory that we have allocated when error occurs. Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()") Signed-off-by: Hewenliang Reviewed-by: Steven Rostedt (VMware) Cc: Tzvetomir Stoyanov Link: http://lore.kernel.org/lkml/20191119014415.57210-1-hewenliang4@huawei.com Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/lib/traceevent/parse-filter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index 5e10ba796a6f..569bceff5f51 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c @@ -1492,8 +1492,10 @@ static int copy_filter_type(struct event_filter *filter, if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) { /* Add trivial event */ arg = allocate_arg(); - if (arg == NULL) + if (arg == NULL) { + free(str); return -1; + } arg->type = FILTER_ARG_BOOLEAN; if (strcmp(str, "TRUE") == 0) @@ -1502,8 +1504,11 @@ static int copy_filter_type(struct event_filter *filter, arg->boolean.value = 0; filter_type = add_filter_type(filter, event->id); - if (filter_type == NULL) + if (filter_type == NULL) { + free(str); + free_arg(arg); return -1; + } filter_type->filter = arg;