[PATCH] Fix dst_destroy() race
Changes
1 files changed · +4 −2
| File | Status | Add | Del | Content |
|---|---|---|---|---|
| net/core/dst.c | modified | +4 | −2 | View file |
net/core/dst.c
View filediff --git a/net/core/dst.c b/net/core/dst.c
index 3bf6cc4..fc434ad 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -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 */
}