ipv4: Fix memory leak in exception case for splitting tries
authorAlexander Duyck <alexander.h.duyck@intel.com>
Tue, 15 Nov 2016 10:46:12 +0000 (05:46 -0500)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Nov 2016 18:24:50 +0000 (13:24 -0500)
Fix a small memory leak that can occur where we leak a fib_alias in the
event of us not being able to insert it into the local table.

Fixes: 0ddcf43d5d4a0 ("ipv4: FIB Local/MAIN table collapse")
Reported-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/fib_trie.c

index 735edc9d41a2965e479ed1dbbea652e5579b9983..026f309c51e9b6143e74efe2d31c8c5e7a7a3c26 100644 (file)
@@ -1743,8 +1743,10 @@ struct fib_table *fib_trie_unmerge(struct fib_table *oldtb)
                                local_l = fib_find_node(lt, &local_tp, l->key);
 
                        if (fib_insert_alias(lt, local_tp, local_l, new_fa,
-                                            NULL, l->key))
+                                            NULL, l->key)) {
+                               kmem_cache_free(fn_alias_kmem, new_fa);
                                goto out;
+                       }
                }
 
                /* stop loop if key wrapped back to 0 */