diff options
author | Ian Rogers <irogers@google.com> | 2023-10-09 20:39:17 +0200 |
---|---|---|
committer | Namhyung Kim <namhyung@kernel.org> | 2023-10-12 19:01:57 +0200 |
commit | c4b5140c6eac2f757d9706c6c783b60554c48cb7 (patch) | |
tree | c4020b92d38b6393b1e4e7666cd322b719d197cc /tools/lib | |
parent | perf parse-events: Fix unlikely memory leak when cloning terms (diff) | |
download | linux-c4b5140c6eac2f757d9706c6c783b60554c48cb7.tar.xz linux-c4b5140c6eac2f757d9706c6c783b60554c48cb7.zip |
tools api: Avoid potential double free
io__getline will free the line on error but it doesn't clear the out
argument. This may lead to the line being freed twice, like in
tools/perf/util/srcline.c as detected by clang-tidy.
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: llvm@lists.linux.dev
Cc: Ming Wang <wangming01@loongson.cn>
Cc: Tom Rix <trix@redhat.com>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20231009183920.200859-17-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/api/io.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/lib/api/io.h b/tools/lib/api/io.h index 9fc429d2852d..a77b74c5fb65 100644 --- a/tools/lib/api/io.h +++ b/tools/lib/api/io.h @@ -180,6 +180,7 @@ static inline ssize_t io__getline(struct io *io, char **line_out, size_t *line_l return line_len; err_out: free(line); + *line_out = NULL; return -ENOMEM; } |