bpf, lpm: fix kfree of im_node in trie_update_elem
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 24 Jan 2017 00:26:46 +0000 (01:26 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Jan 2017 02:17:35 +0000 (21:17 -0500)
We need to initialize im_node to NULL, otherwise in case of error path
it gets passed to kfree() as uninitialized pointer.

Fixes: b95a5c4db09b ("bpf: add a longest prefix match trie map implementation")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/lpm_trie.c

index ba19241d1979bcfc65485d859b59c2a585ca1097..144e9763102fb3382a068bfc6592525a4085b1f0 100644 (file)
@@ -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;