Skip to content

Commit

Permalink
bpftool: Check malloc return value in mount_bpffs_for_pin
Browse files Browse the repository at this point in the history
[ Upstream commit d444b06 ]

Fix and add a missing NULL check for the prior malloc() call.

Fixes: 49a086c ("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>
  • Loading branch information
tklauser authored and gregkh committed Jul 28, 2021
1 parent 3b5b0af commit 2fc8048
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/bpf/bpftool/common.c
Expand Up @@ -221,6 +221,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);

Expand Down

0 comments on commit 2fc8048

Please sign in to comment.