From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756625Ab3IKFJj (ORCPT ); Wed, 11 Sep 2013 01:09:39 -0400 Received: from lgeamrelo02.lge.com ([156.147.1.126]:55155 "EHLO LGEAMRELO02.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753026Ab3IKFJf (ORCPT ); Wed, 11 Sep 2013 01:09:35 -0400 X-AuditID: 9c93017e-b7c00ae000002eb6-67-522ffb0e289e From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Paul Mackerras , Ingo Molnar , Namhyung Kim , LKML , Jiri Olsa Subject: [PATCH 1/9] perf sort: Fix a memory leak on srcline Date: Wed, 11 Sep 2013 14:09:25 +0900 Message-Id: <1378876173-13363-2-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1378876173-13363-1-git-send-email-namhyung@kernel.org> References: <1378876173-13363-1-git-send-email-namhyung@kernel.org> X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim In the hist_entry__srcline_snprintf(), path and self->srcline are pointing the same memory region, but they are doubly allocated. Reviewed-by: Jiri Olsa Signed-off-by: Namhyung Kim --- tools/perf/util/sort.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 5f118a089519..5ba29fc679c5 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -269,10 +269,7 @@ static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf, if (!fp) goto out_ip; - if (getline(&path, &line_len, fp) < 0 || !line_len) - goto out_ip; - self->srcline = strdup(path); - if (self->srcline == NULL) + if (getline(&self->srcline, &line_len, fp) < 0 || !line_len) goto out_ip; nl = strchr(self->srcline, '\n'); -- 1.7.11.7