diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2021-07-15 13:06:09 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-07-28 11:13:48 +0200 |
commit | 10b5522407b93fd31d73c8ae8779dc8009744f31 (patch) | |
tree | 7d1af7af3a095f994f19510e88995adc0e9c2227 | |
parent | 0d0927f545aeaf64f39d0618ae568ae8b1a668f3 (diff) | |
download | linux-10b5522407b93fd31d73c8ae8779dc8009744f31.tar.gz linux-10b5522407b93fd31d73c8ae8779dc8009744f31.tar.bz2 linux-10b5522407b93fd31d73c8ae8779dc8009744f31.zip |
bpftool: Check malloc return value in mount_bpffs_for_pin
[ Upstream commit d444b06e40855219ef38b5e9286db16d435f06dc ]
Fix and add a missing NULL check for the prior malloc() call.
Fixes: 49a086c201a9 ("bpftool: implement prog load command")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Acked-by: Roman Gushchin <guro@fb.com>
Link: https://lore.kernel.org/bpf/20210715110609.29364-1-tklauser@distanz.ch
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | tools/bpf/bpftool/common.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c index 158469f57461..7faf24ef3c80 100644 --- a/tools/bpf/bpftool/common.c +++ b/tools/bpf/bpftool/common.c @@ -182,6 +182,11 @@ int do_pin_fd(int fd, const char *name) goto out; file = malloc(strlen(name) + 1); + if (!file) { + p_err("mem alloc failed"); + return -1; + } + strcpy(file, name); dir = dirname(file); |