diff options
| author | Tobias Klauser <[email protected]> | 2021-07-15 11:06:09 +0000 |
|---|---|---|
| committer | Daniel Borkmann <[email protected]> | 2021-07-15 18:01:36 +0000 |
| commit | d444b06e40855219ef38b5e9286db16d435f06dc (patch) | |
| tree | fdf9d10f6aff6fb293f6cf22665fc66fda2151b7 /tools/bpf/bpftool/common.c | |
| parent | bpf, sockmap, udp: sk_prot needs inuse_idx set for proc stats (diff) | |
| download | kernel-d444b06e40855219ef38b5e9286db16d435f06dc.tar.gz kernel-d444b06e40855219ef38b5e9286db16d435f06dc.zip | |
bpftool: Check malloc return value in mount_bpffs_for_pin
Fix and add a missing NULL check for the prior malloc() call.
Fixes: 49a086c201a9 ("bpftool: implement prog load command")
Signed-off-by: Tobias Klauser <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]>
Acked-by: Roman Gushchin <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/bpf/bpftool/common.c')
| -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 1828bba19020..dc6daa193557 100644 --- a/tools/bpf/bpftool/common.c +++ b/tools/bpf/bpftool/common.c @@ -222,6 +222,11 @@ int mount_bpffs_for_pin(const char *name) int err = 0; file = malloc(strlen(name) + 1); + if (!file) { + p_err("mem alloc failed"); + return -1; + } + strcpy(file, name); dir = dirname(file); |
