[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210726153832.976453423@linuxfoundation.org>
Date: Mon, 26 Jul 2021 17:38:41 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Tobias Klauser <tklauser@...tanz.ch>,
Daniel Borkmann <daniel@...earbox.net>,
Quentin Monnet <quentin@...valent.com>,
Roman Gushchin <guro@...com>, Sasha Levin <sashal@...nel.org>
Subject: [PATCH 5.4 040/108] bpftool: Check malloc return value in mount_bpffs_for_pin
From: Tobias Klauser <tklauser@...tanz.ch>
[ Upstream commit d444b06e40855219ef38b5e9286db16d435f06dc ]
Fix and add a missing NULL check for the prior malloc() call.
Fixes: 49a086c201a9 ("bpftool: implement prog load command")
Signed-off-by: Tobias Klauser <tklauser@...tanz.ch>
Signed-off-by: Daniel Borkmann <daniel@...earbox.net>
Reviewed-by: Quentin Monnet <quentin@...valent.com>
Acked-by: Roman Gushchin <guro@...com>
Link: https://lore.kernel.org/bpf/20210715110609.29364-1-tklauser@distanz.ch
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
tools/bpf/bpftool/common.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 88264abaa738..a209f53901b8 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -171,6 +171,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);
--
2.30.2
Powered by blists - more mailing lists