Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2280981ybc; Wed, 13 Nov 2019 11:49:03 -0800 (PST) X-Google-Smtp-Source: APXvYqxBXXx9quYMV8IS2ZFbIPiSHlkJ/IHh+HiOsn+yrBmBIzDdVWS6pzvyW4/Uo3sMr3H3yB/w X-Received: by 2002:a50:84e9:: with SMTP id 96mr5588635edq.182.1573674542943; Wed, 13 Nov 2019 11:49:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573674542; cv=none; d=google.com; s=arc-20160816; b=uvU40jy8TfI00iI0wCafviaZPnoQzdJuuxr64m5WBU8lXrrmIdNr42usS3CwkLsQ8u JsYkho4hiyAth6NHifSQlu92+qfI/mq9QoWJx/U+ey9b9EySL9+aNjBIZhRQsLhD17jK baLNylI9Q0oCVNgVVANilL0K+rekwc0OjJaIW5rjislybvwt4l9J70y4AXwn7TTfo6lA G8sbduuTBEycHjQSl6aT6RqQxHgIc20TZuRWwHsW70qaesS0iMr8TifGH9rgAz1v0+BC fOx3pLG4IblB8UJt5ACYKqDH4uGkfM697OWpwmwAyOEJtI98Fu6vEZesQzKQ8QnB3vqW dAdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=K6Min7k482NSiNa4l6ym2ij+a30fLZkfjukQNZo2j6w=; b=XLwATDg7fkgb9hpvVDD02YB6ompR6U8J/Z7LhrBTzlrklqa02r7CH2YTytQ66hJqT3 7VXOhQf50WxAsclmrE1kHz5xr2/+Yf5JSvhPZ/yetKncj7kogBFERBt5VZe7dyj2UjDP GDDlnv60hYpIYwyIdoAfFhE+MOeGB4wT3dkDR0p4MYzc56bFmvbChrwqircYjMyYckGX 4Qbgtir9me4HAfE/QK9I6sORgS6/Zhjxtoi7mG3YrVuC0vSSL5PdYAyi17Yy8Aiy/rd+ fgWam0P1bXCnHpdLjjToYyq2dPIXSWoAVud5HeMoA4TzAEfTGDd1swckhxoN1egweFB0 KLuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si1858419ejd.66.2019.11.13.11.48.37; Wed, 13 Nov 2019 11:49:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726598AbfKMTsA (ORCPT + 99 others); Wed, 13 Nov 2019 14:48:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:45010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbfKMTsA (ORCPT ); Wed, 13 Nov 2019 14:48:00 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 AAA84206ED; Wed, 13 Nov 2019 19:47:59 +0000 (UTC) Date: Wed, 13 Nov 2019 14:47:57 -0500 From: Steven Rostedt To: Hewenliang , Cc: , , , Subject: Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type Message-ID: <20191113144757.2c4ca83b@gandalf.local.home> In-Reply-To: <20191113144626.44ad5418@gandalf.local.home> References: <20191025082312.62690-1-hewenliang4@huawei.com> <20191113144626.44ad5418@gandalf.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Nov 2019 14:46:26 -0500 Steven Rostedt wrote: > On Fri, 25 Oct 2019 04:23:12 -0400 > Hewenliang wrote: > > > 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) After I sent this, I found an issue. > > Arnaldo, > > Can you take this? Don't take it. > > > --- > > 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 552592d153fb..fbaa790d10d8 100644 > > --- a/tools/lib/traceevent/parse-filter.c > > +++ b/tools/lib/traceevent/parse-filter.c > > @@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_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 = TEP_FILTER_ARG_BOOLEAN; > > if (strcmp(str, "TRUE") == 0) > > @@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_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); This needs to be: free_arg(arg); -- Steve > > return -1; > > + } > > > > filter_type->filter = arg; > > >