Commit abcdeaaf authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[IPSEC]: Do not leak entries in xfrm_state_find.

In xfrm_state_find, the larval state never actually matures with
Openswan so it only ever gets deleted by the timer which means
that the time crash can't happen :)  It becomes a (possible) memory
leak instead.
parent 60a6680d
...@@ -331,14 +331,8 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, ...@@ -331,14 +331,8 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
} }
} }
if (best) { x = best;
xfrm_state_hold(best); if (!x && !error && !acquire_in_progress &&
spin_unlock_bh(&xfrm_state_lock);
return best;
}
x = NULL;
if (!error && !acquire_in_progress &&
((x = xfrm_state_alloc()) != NULL)) { ((x = xfrm_state_alloc()) != NULL)) {
/* Initialize temporary selector matching only /* Initialize temporary selector matching only
* to current session. */ * to current session. */
...@@ -363,10 +357,12 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, ...@@ -363,10 +357,12 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
error = 1; error = 1;
} }
} }
spin_unlock_bh(&xfrm_state_lock); if (x)
if (!x) xfrm_state_hold(x);
else
*err = acquire_in_progress ? -EAGAIN : *err = acquire_in_progress ? -EAGAIN :
(error ? -ESRCH : -ENOMEM); (error ? -ESRCH : -ENOMEM);
spin_unlock_bh(&xfrm_state_lock);
return x; return x;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment