[PATCH 1/5] perf dso: Guard against errno==0 when dso__get_filename() returns NULL
Arnaldo Carvalho de Melo <[email protected]> Sun, 2 Aug 2026 11:20:18 -0300
| Newsgroups | org.kernel.vger.linux-perf-users,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
From: Arnaldo Carvalho de Melo <[email protected]> __open_dso() computes fd = -errno when dso__get_filename() returns NULL. Some failure paths in dso__get_filename() (e.g. binary type mismatch) return NULL without making a syscall, leaving errno at 0 from a prior successful call. fd = -0 = 0, which is stdin — subsequent code treats it as a valid file descriptor. Fall back to ENOENT when errno is 0, ensuring fd is always negative on failure. Fixes: eba5102d2f0b ("perf tools: Add global list of opened dso objects") Reported-by: sashiko-bot <[email protected]> Cc: Jiri Olsa <[email protected]> Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> --- tools/perf/util/dso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 2309196d8df3111c..e087a89066bdbc02 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -643,7 +643,7 @@ static int __open_dso(struct dso *dso, struct machine *machine) if (name) fd = do_open(name); else - fd = -errno; + fd = errno ? -errno : -ENOENT; if (decomp) unlink(name); -- 2.55.0