Skip to content

Commit 64f5a10

Browse files
Hou TaoSasha Levin
authored andcommitted
bpf: Remove unnecessary kfree(im_node) in lpm_trie_update_elem
[ Upstream commit 3d5611b ] There is no need to call kfree(im_node) when updating element fails, because im_node must be NULL. Remove the unnecessary kfree() for im_node. Reviewed-by: Toke Høiland-Jørgensen <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Signed-off-by: Hou Tao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]> Stable-dep-of: 532d6b3 ("bpf: Handle in-place update for full LPM trie correctly") Signed-off-by: Sasha Levin <[email protected]>
1 parent c52cd8b commit 64f5a10

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

kernel/bpf/lpm_trie.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ static long trie_update_elem(struct bpf_map *map,
315315
void *_key, void *value, u64 flags)
316316
{
317317
struct lpm_trie *trie = container_of(map, struct lpm_trie, map);
318-
struct lpm_trie_node *node, *im_node = NULL, *new_node = NULL;
318+
struct lpm_trie_node *node, *im_node, *new_node = NULL;
319319
struct lpm_trie_node *free_node = NULL;
320320
struct lpm_trie_node __rcu **slot;
321321
struct bpf_lpm_trie_key_u8 *key = _key;
@@ -449,9 +449,7 @@ static long trie_update_elem(struct bpf_map *map,
449449
if (ret) {
450450
if (new_node)
451451
trie->n_entries--;
452-
453452
kfree(new_node);
454-
kfree(im_node);
455453
}
456454

457455
spin_unlock_irqrestore(&trie->lock, irq_flags);

0 commit comments

Comments
 (0)