projects
/
platform
/
kernel
/
linux-rpi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
678a1c0
)
libbpf: Restore errno after pr_warn.
author
Alexei Starovoitov
<ast@kernel.org>
Fri, 30 Dec 2022 03:12:17 +0000
(19:12 -0800)
committer
Alexei Starovoitov
<ast@kernel.org>
Fri, 30 Dec 2022 03:18:08 +0000
(19:18 -0800)
pr_warn calls into user-provided callback, which can clobber errno, so
`errno = saved_errno` should happen after pr_warn.
Fixes:
07453245620c
("libbpf: fix errno is overwritten after being closed.")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/libbpf_internal.h
patch
|
blob
|
history
diff --git
a/tools/lib/bpf/libbpf_internal.h
b/tools/lib/bpf/libbpf_internal.h
index
98333a6
..
e4d0566
100644
(file)
--- a/
tools/lib/bpf/libbpf_internal.h
+++ b/
tools/lib/bpf/libbpf_internal.h
@@
-544,8
+544,10
@@
static inline int ensure_good_fd(int fd)
saved_errno = errno;
close(old_fd);
errno = saved_errno;
- if (fd < 0)
+ if (fd < 0)
{
pr_warn("failed to dup FD %d to FD > 2: %d\n", old_fd, -saved_errno);
+ errno = saved_errno;
+ }
}
return fd;
}