Skip to content

Commit

Permalink
[IPSEC] flow: Fix potential memory leak
Browse files Browse the repository at this point in the history
When old flow cache entries that are not at the head of their chain
trigger a transient security error they get unlinked along with all
the entries preceding them in the chain.  The preceding entries are
not freed correctly.

This patch fixes this by simply leaving the entry around.  It's based
on a suggestion by Venkat Yekkirala.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Jan 24, 2007
1 parent 419dd83 commit e0e8f1c
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions net/core/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,22 +231,16 @@ void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir,

err = resolver(key, family, dir, &obj, &obj_ref);

if (fle) {
if (err) {
/* Force security policy check on next lookup */
*head = fle->next;
flow_entry_kill(cpu, fle);
} else {
fle->genid = atomic_read(&flow_cache_genid);

if (fle->object)
atomic_dec(fle->object_ref);

fle->object = obj;
fle->object_ref = obj_ref;
if (obj)
atomic_inc(fle->object_ref);
}
if (fle && !err) {
fle->genid = atomic_read(&flow_cache_genid);

if (fle->object)
atomic_dec(fle->object_ref);

fle->object = obj;
fle->object_ref = obj_ref;
if (obj)
atomic_inc(fle->object_ref);
}
local_bh_enable();

Expand Down

0 comments on commit e0e8f1c

Please sign in to comment.