Skip to content

Commit f7af86e

Browse files
visitorckwWangYuli
authored andcommitted
perf hisi-ptt: Fix memory leak in lseek failure handling
[Upstream commit be7a4ca] In the previous code, there was a memory leak issue where the previously allocated memory was not freed upon a failed lseek operation. This patch addresses the problem by releasing the old memory before returning -errno in case of a lseek failure. This ensures that memory is properly managed and avoids potential memory leaks. Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: yangyicong@hisilicon.com Cc: jonathan.cameron@huawei.com Link: https://lore.kernel.org/r/20230930072719.1267784-1-visitorckw@gmail.com Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: huwentao <wentaohu0417@163.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
1 parent 69e2e6e commit f7af86e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/perf/util/hisi-ptt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ static int hisi_ptt_process_auxtrace_event(struct perf_session *session,
108108
data_offset = 0;
109109
} else {
110110
data_offset = lseek(fd, 0, SEEK_CUR);
111-
if (data_offset == -1)
111+
if (data_offset == -1) {
112+
free(data);
112113
return -errno;
114+
}
113115
}
114116

115117
err = readn(fd, data, size);

0 commit comments

Comments
 (0)