summaryrefslogtreecommitdiff
path: root/tools/perf/util/libbfd.c
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2025-12-06 18:23:45 -0800
committerNamhyung Kim <namhyung@kernel.org>2025-12-17 07:30:51 -0800
commit5c5f6fe32df2edb4f72bdca62ec2b9f20b7c5ba4 (patch)
treebf351ba9a25b63397ce6d8d5e9ac74cb98958096 /tools/perf/util/libbfd.c
parent800ad1f0e27792cddf5928f590d3f2d4ab3c68ee (diff)
perf symbol: Fix ENOENT case for filename__read_build_id
Some callers of filename__read_build_id assume the error value must be -1, fix by making them handle all < 0 values. If is_regular_file fails in filename__read_build_id then it could be the file is missing (ENOENT) and it would be wrong to return -EWOULDBLOCK in that case. Fix the logic so -EWOULDBLOCK is only reported if other errors with stat haven't occurred. Fixes: 834ebb5678d7 ("perf tools: Don't read build-ids from non-regular files") Signed-off-by: Ian Rogers <irogers@google.com> Reviewed-by: James Clark <james.clark@linaro.org> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf/util/libbfd.c')
-rw-r--r--tools/perf/util/libbfd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/perf/util/libbfd.c b/tools/perf/util/libbfd.c
index cc0c474cbfaa..79f4528234a9 100644
--- a/tools/perf/util/libbfd.c
+++ b/tools/perf/util/libbfd.c
@@ -426,8 +426,10 @@ int libbfd__read_build_id(const char *filename, struct build_id *bid)
if (!filename)
return -EFAULT;
+
+ errno = 0;
if (!is_regular_file(filename))
- return -EWOULDBLOCK;
+ return errno == 0 ? -EWOULDBLOCK : -errno;
fd = open(filename, O_RDONLY);
if (fd < 0)