Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Ian Rogers and committed by
Namhyung Kim
5c5f6fe3 800ad1f0

+13 -5
+4 -2
tools/perf/builtin-buildid-cache.c
··· 276 276 { 277 277 char filename[PATH_MAX]; 278 278 struct build_id bid = { .size = 0, }; 279 + int err; 279 280 280 281 if (!dso__build_id_filename(dso, filename, sizeof(filename), false)) 281 282 return true; 282 283 283 - if (filename__read_build_id(filename, &bid) == -1) { 284 - if (errno == ENOENT) 284 + err = filename__read_build_id(filename, &bid); 285 + if (err < 0) { 286 + if (err == -ENOENT) 285 287 return false; 286 288 287 289 pr_warning("Problems with %s file, consider removing it from the cache\n",
+3 -1
tools/perf/util/libbfd.c
··· 426 426 427 427 if (!filename) 428 428 return -EFAULT; 429 + 430 + errno = 0; 429 431 if (!is_regular_file(filename)) 430 - return -EWOULDBLOCK; 432 + return errno == 0 ? -EWOULDBLOCK : -errno; 431 433 432 434 fd = open(filename, O_RDONLY); 433 435 if (fd < 0)
+3 -1
tools/perf/util/symbol-elf.c
··· 902 902 903 903 if (!filename) 904 904 return -EFAULT; 905 + 906 + errno = 0; 905 907 if (!is_regular_file(filename)) 906 - return -EWOULDBLOCK; 908 + return errno == 0 ? -EWOULDBLOCK : -errno; 907 909 908 910 err = kmod_path__parse(&m, filename); 909 911 if (err)
+3 -1
tools/perf/util/symbol-minimal.c
··· 104 104 105 105 if (!filename) 106 106 return -EFAULT; 107 + 108 + errno = 0; 107 109 if (!is_regular_file(filename)) 108 - return -EWOULDBLOCK; 110 + return errno == 0 ? -EWOULDBLOCK : -errno; 109 111 110 112 fd = open(filename, O_RDONLY); 111 113 if (fd < 0)