Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipv4: Fix fib_info->fib_metrics leak

Commit 4670994d(net,rcu: convert call_rcu(fc_rport_free_rcu) to
kfree_rcu()) introduced a memory leak. This patch reverts it.

Signed-off-by: Zheng Yan <zheng.z.yan@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Yan, Zheng and committed by
David S. Miller
19c1ea14 4fb66b82

+9 -1
+9 -1
net/ipv4/fib_semantics.c
··· 142 142 }; 143 143 144 144 /* Release a nexthop info record */ 145 + static void free_fib_info_rcu(struct rcu_head *head) 146 + { 147 + struct fib_info *fi = container_of(head, struct fib_info, rcu); 148 + 149 + if (fi->fib_metrics != (u32 *) dst_default_metrics) 150 + kfree(fi->fib_metrics); 151 + kfree(fi); 152 + } 145 153 146 154 void free_fib_info(struct fib_info *fi) 147 155 { ··· 164 156 } endfor_nexthops(fi); 165 157 fib_info_cnt--; 166 158 release_net(fi->fib_net); 167 - kfree_rcu(fi, rcu); 159 + call_rcu(&fi->rcu, free_fib_info_rcu); 168 160 } 169 161 170 162 void fib_release_info(struct fib_info *fi)