mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
bpftool: Check malloc return value in mount_bpffs_for_pin
Fix and add a missing NULL check for the prior malloc() call.
Fixes: 49a086c201
("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
This commit is contained in:
parent
54ea2f49fd
commit
d444b06e40
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user