Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757076AbaFALgF (ORCPT ); Sun, 1 Jun 2014 07:36:05 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:45404 "EHLO mail-we0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751929AbaFALgE (ORCPT ); Sun, 1 Jun 2014 07:36:04 -0400 From: Rickard Strandqvist To: Arnaldo Carvalho de Melo , Namhyung Kim Cc: Rickard Strandqvist , Steven Rostedt , linux-kernel@vger.kernel.org Subject: [PATCH] tools: lib: traceevent: parse-filter.c: Cleaning up memory leak Date: Sun, 1 Jun 2014 13:36:56 +0200 Message-Id: <1401622616-13721-1-git-send-email-rickard_strandqvist@spectrumdigital.se> X-Mailer: git-send-email 1.7.10.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a risk for memory leak in when something unexpected happens and the function returns. This was largely found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist --- tools/lib/traceevent/parse-filter.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index b502344..5865c9e 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, arg->boolean.value = 0; filter_type = add_filter_type(filter, event->id); - if (filter_type == NULL) + if (filter_type == NULL) { + free_arg(arg); return -1; + } filter_type->filter = arg; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/