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);