mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 08:46:46 +00:00
net/flow: Fix potential memory leak
While preparing net flow caches, once a fail may cause potential memory leak , fix it. Signed-off-by: Huajun Li <huajun.li.lee@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e6f8aa9b90
commit
6ccc3abdc9
1 changed files with 13 additions and 1 deletions
|
@ -413,7 +413,7 @@ static int __init flow_cache_init(struct flow_cache *fc)
|
||||||
|
|
||||||
for_each_online_cpu(i) {
|
for_each_online_cpu(i) {
|
||||||
if (flow_cache_cpu_prepare(fc, i))
|
if (flow_cache_cpu_prepare(fc, i))
|
||||||
return -ENOMEM;
|
goto err;
|
||||||
}
|
}
|
||||||
fc->hotcpu_notifier = (struct notifier_block){
|
fc->hotcpu_notifier = (struct notifier_block){
|
||||||
.notifier_call = flow_cache_cpu,
|
.notifier_call = flow_cache_cpu,
|
||||||
|
@ -426,6 +426,18 @@ static int __init flow_cache_init(struct flow_cache *fc)
|
||||||
add_timer(&fc->rnd_timer);
|
add_timer(&fc->rnd_timer);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err:
|
||||||
|
for_each_possible_cpu(i) {
|
||||||
|
struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, i);
|
||||||
|
kfree(fcp->hash_table);
|
||||||
|
fcp->hash_table = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
free_percpu(fc->percpu);
|
||||||
|
fc->percpu = NULL;
|
||||||
|
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init flow_cache_init_global(void)
|
static int __init flow_cache_init_global(void)
|
||||||
|
|
Loading…
Reference in a new issue