mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
[PATCH] Fix dst_destroy() race
When we are not the real parent of the dst (e.g., when we're xfrm_dst and the child is an rtentry), it may already be on the GC list. In fact the current code is buggy to, we need to check dst->flags before the dec as dst may no longer be valid afterwards. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
2a27805127
commit
6775cab98b
1 changed files with 4 additions and 2 deletions
|
@ -198,13 +198,15 @@ again:
|
|||
|
||||
dst = child;
|
||||
if (dst) {
|
||||
int nohash = dst->flags & DST_NOHASH;
|
||||
|
||||
if (atomic_dec_and_test(&dst->__refcnt)) {
|
||||
/* We were real parent of this dst, so kill child. */
|
||||
if (dst->flags&DST_NOHASH)
|
||||
if (nohash)
|
||||
goto again;
|
||||
} else {
|
||||
/* Child is still referenced, return it for freeing. */
|
||||
if (dst->flags&DST_NOHASH)
|
||||
if (nohash)
|
||||
return dst;
|
||||
/* Child is still in his hash table */
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue