]> Git Repo - linux.git/commitdiff
bpftool: Check malloc return value in mount_bpffs_for_pin
authorTobias Klauser <[email protected]>
Thu, 15 Jul 2021 11:06:09 +0000 (13:06 +0200)
committerDaniel Borkmann <[email protected]>
Thu, 15 Jul 2021 18:01:36 +0000 (20:01 +0200)
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]
tools/bpf/bpftool/common.c

index 1828bba19020d6cce0df684c8d1c3c4e9dc73cc5..dc6daa193557a9c6647a18ed363fafcfb7026b8a 100644 (file)
@@ -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);
 
This page took 0.063925 seconds and 4 git commands to generate.