提交 6e444cd1 编写于 作者: T Tobias Klauser 提交者: Zheng Zengkai

bpftool: Check malloc return value in mount_bpffs_for_pin

stable inclusion
from stable-5.10.54
commit 2fc8048265ce8a4357addac6874e2fad905134be
bugzilla: 175586 https://gitee.com/openeuler/kernel/issues/I4DVDU

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2fc8048265ce8a4357addac6874e2fad905134be

--------------------------------

[ Upstream commit d444b06e ]

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

Fixes: 49a086c2 ("bpftool: implement prog load command")
Signed-off-by: NTobias Klauser <tklauser@distanz.ch>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Reviewed-by: NQuentin Monnet <quentin@isovalent.com>
Acked-by: NRoman Gushchin <guro@fb.com>
Link: https://lore.kernel.org/bpf/20210715110609.29364-1-tklauser@distanz.chSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 7776f5d2
...@@ -221,6 +221,11 @@ int mount_bpffs_for_pin(const char *name) ...@@ -221,6 +221,11 @@ int mount_bpffs_for_pin(const char *name)
int err = 0; int err = 0;
file = malloc(strlen(name) + 1); file = malloc(strlen(name) + 1);
if (!file) {
p_err("mem alloc failed");
return -1;
}
strcpy(file, name); strcpy(file, name);
dir = dirname(file); dir = dirname(file);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册