Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp892875yba; Thu, 18 Apr 2019 11:19:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkPxXNTqHjE5oqyCunqdBshlBbTYrNPl+VJkLi+6UeqXHgBkDQpyLkNRjpbXlQAos+oH8O X-Received: by 2002:a63:360e:: with SMTP id d14mr88886114pga.188.1555611563550; Thu, 18 Apr 2019 11:19:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611563; cv=none; d=google.com; s=arc-20160816; b=uUyartQVryy0vKkHQldW0AIgvPd/uJOA/O1tz4VtEq3cn2RyJgiqgC6jHFQgELv0qh cgnIC3tbk09vU769sNf6lT/IjUKRY4qmOwrer4Ck8UUjRzHgYHcv0tajE6AES4scHy5o g+KZwspxkXeH8EmdzTLC6T7NMCHRCFKwNXecwsXvkqDYwjBh8nK/kmddzh2R9ebvBdLk liShEI1ANZyymkSNhbfcjRml75hw+N9jw6dLJh8kBnpakVMb538vXc2G4UAH1fEnDJbS tPgqBDpJYYPAaUFgMe8fS/F5TUnCT9lsA3IGP/wiM4t6jx3IT/GpuFkY9U0TkRnTiNuA YYpg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n5Q8NjaV+dYwwhlL8LDdwXH8ViDleWeHYgzYDH11qZk=; b=Ie8WfpT8ZftvP81M9HMwP+2lvltqfjQp63y2dQgpHDv91BCMD4MLTfaXyDJ+ewL1Y1 62xzx2nkl5lKGKZTs0WZtr3bf9H9/FWOZu05heEQ4yHCbWcTeF5i2MeTC9+2UsjQfg97 C9XlONjAaBfc6yTYHsfNZjcFVX79CWVrSBObwVaq0drm9t0UnqcczhgoI7mr33LyDDz2 ATbY3pDFwS4Xhxue9gWT3L92DRSjB8H+mkN5DmWv3aR8xjg5TSQwuTq0qZexIkqPNUKr PuRQugRbkWYMlHt547q47o3j6idbaI5Hb5Yk6tuOTbCM/8QZJb0JV4RkIO563XK4MjZY ETuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="AGaqh/aH"; 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 o4si1750746plb.425.2019.04.18.11.19.08; Thu, 18 Apr 2019 11:19:23 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b="AGaqh/aH"; 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 S2404299AbfDRSRm (ORCPT + 99 others); Thu, 18 Apr 2019 14:17:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:43236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391797AbfDRSLJ (ORCPT ); Thu, 18 Apr 2019 14:11:09 -0400 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 55A1021872; Thu, 18 Apr 2019 18:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611068; bh=AIvmDoMJ+MW+8VnR42M59AVC4Yo8iRiSIjFSAjd0o2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AGaqh/aHyW26y+mMYhiGHO4029M1xv8hqgFVSsX164cp7vgE9bLUSYEsGF2SBqeB9 uHymRcM48g0SIxoTeNt4i4+bz/HzAq3DT4mkmlh1D2rhHLR0oIqrF3BO4fXRrm+Nm2 Rd8ZXxaSFo1h8j3HJ++7gcpkF8jHP2RVwC/aScWU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Changbin Du , Alexei Starovoitov , Andi Kleen , Daniel Borkmann , Jiri Olsa , Namhyung Kim , Peter Zijlstra , "Steven Rostedt (VMware)" , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.0 47/93] perf tests: Fix memory leak by expr__find_other() in test__expr() Date: Thu, 18 Apr 2019 19:57:25 +0200 Message-Id: <20190418160442.413553766@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160436.781762249@linuxfoundation.org> References: <20190418160436.781762249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit f97a8991d3b998e518f56794d879f645964de649 ] ================================================================= ==7506==ERROR: LeakSanitizer: detected memory leaks Direct leak of 13 byte(s) in 3 object(s) allocated from: #0 0x7f03339d6070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070) #1 0x5625e53aaef0 in expr__find_other util/expr.y:221 #2 0x5625e51bcd3f in test__expr tests/expr.c:52 #3 0x5625e51528e6 in run_test tests/builtin-test.c:358 #4 0x5625e5152baf in test_and_print tests/builtin-test.c:388 #5 0x5625e51543fe in __cmd_test tests/builtin-test.c:583 #6 0x5625e515572f in cmd_test tests/builtin-test.c:722 #7 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302 #8 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354 #9 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398 #10 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520 #11 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) Signed-off-by: Changbin Du Cc: Alexei Starovoitov Cc: Andi Kleen Cc: Daniel Borkmann Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Steven Rostedt (VMware) Fixes: 075167363f8b ("perf tools: Add a simple expression parser for JSON") Link: http://lkml.kernel.org/r/20190316080556.3075-16-changbin.du@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/tests/expr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c index 01f0706995a9..9acc1e80b936 100644 --- a/tools/perf/tests/expr.c +++ b/tools/perf/tests/expr.c @@ -19,7 +19,7 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused) const char *p; const char **other; double val; - int ret; + int i, ret; struct parse_ctx ctx; int num_other; @@ -56,6 +56,9 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused) TEST_ASSERT_VAL("find other", !strcmp(other[1], "BAZ")); TEST_ASSERT_VAL("find other", !strcmp(other[2], "BOZO")); TEST_ASSERT_VAL("find other", other[3] == NULL); + + for (i = 0; i < num_other; i++) + free((void *)other[i]); free((void *)other); return 0; -- 2.19.1