Skip to content

Commit 2fc8048

Browse files
tklausergregkh
authored andcommitted
bpftool: Check malloc return value in mount_bpffs_for_pin
[ 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>
1 parent 3b5b0af commit 2fc8048

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎tools/bpf/bpftool/common.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ int mount_bpffs_for_pin(const char *name)
221221
int err = 0;
222222

223223
file = malloc(strlen(name) + 1);
224+
if (!file) {
225+
p_err("mem alloc failed");
226+
return -1;
227+
}
228+
224229
strcpy(file, name);
225230
dir = dirname(file);
226231

0 commit comments

Comments
 (0)