From: Colin King <colin.king@canonical.com>
To: Alexei Starovoitov <ast@kernel.org>, netdev@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] bpf: don't kfree an uninitialized im_node
Date: Tue, 24 Jan 2017 14:16:29 +0000 [thread overview]
Message-ID: <20170124141629.9200-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
There are some error exit paths to the label 'out' that end up
kfree'ing an uninitialized im_node. Fix this by inititializing
im_node to NULL to avoid kfree'ing a garbage address.
Issue found by CoverityScan, CID#1398022 ("Uninitialized pointer read")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
kernel/bpf/lpm_trie.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c
index ba19241d..144e976 100644
--- a/kernel/bpf/lpm_trie.c
+++ b/kernel/bpf/lpm_trie.c
@@ -262,7 +262,7 @@ static int trie_update_elem(struct bpf_map *map,
void *_key, void *value, u64 flags)
{
struct lpm_trie *trie = container_of(map, struct lpm_trie, map);
- struct lpm_trie_node *node, *im_node, *new_node = NULL;
+ struct lpm_trie_node *node, *im_node = NULL, *new_node = NULL;
struct lpm_trie_node __rcu **slot;
struct bpf_lpm_trie_key *key = _key;
unsigned long irq_flags;
--
2.10.2
next reply other threads:[~2017-01-24 14:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 14:16 Colin King [this message]
2017-01-24 17:53 ` [PATCH] bpf: don't kfree an uninitialized im_node Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170124141629.9200-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=ast@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox