* [PATCH v3] net/flow: Fix potential memory leak
@ 2011-09-28 8:51 Huajun Li
2011-10-17 23:19 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Huajun Li @ 2011-09-28 8:51 UTC (permalink / raw)
To: David Miller; +Cc: Eric Dumazet, netdev, Huajun Li
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>
---
net/core/flow.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/net/core/flow.c b/net/core/flow.c
index 555a456..8ae42de 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -413,7 +413,7 @@ static int __init flow_cache_init(struct flow_cache *fc)
for_each_online_cpu(i) {
if (flow_cache_cpu_prepare(fc, i))
- return -ENOMEM;
+ goto err;
}
fc->hotcpu_notifier = (struct notifier_block){
.notifier_call = flow_cache_cpu,
@@ -426,6 +426,18 @@ static int __init flow_cache_init(struct flow_cache *fc)
add_timer(&fc->rnd_timer);
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)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] net/flow: Fix potential memory leak
2011-09-28 8:51 [PATCH v3] net/flow: Fix potential memory leak Huajun Li
@ 2011-10-17 23:19 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-10-17 23:19 UTC (permalink / raw)
To: huajun.li.lee; +Cc: eric.dumazet, netdev
From: Huajun Li <huajun.li.lee@gmail.com>
Date: Wed, 28 Sep 2011 16:51:39 +0800
> 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>
Applied to net-next, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-10-17 23:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-28 8:51 [PATCH v3] net/flow: Fix potential memory leak Huajun Li
2011-10-17 23:19 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).