diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-02-03 21:33:22 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-05 05:34:52 +0100 |
commit | 28134a53d624ae7e90fff8500b25b3add4d40b92 (patch) | |
tree | f919a71660f25f7d50c927df06df0d265cff2524 /lib | |
parent | NetCP: Deletion of unnecessary checks before two function calls (diff) | |
download | linux-28134a53d624ae7e90fff8500b25b3add4d40b92.tar.xz linux-28134a53d624ae7e90fff8500b25b3add4d40b92.zip |
rhashtable: Fix potential crash on destroy in rhashtable_shrink
The current being_destroyed check in rhashtable_expand is not
enough since if we start a shrinking process after freeing all
elements in the table that's also going to crash.
This patch adds a being_destroyed check to the deferred worker
thread so that we bail out as soon as we take the lock.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rhashtable.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/rhashtable.c b/lib/rhashtable.c index c41e21096373..904b419b72f5 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -487,6 +487,9 @@ static void rht_deferred_worker(struct work_struct *work) ht = container_of(work, struct rhashtable, run_work); mutex_lock(&ht->mutex); + if (ht->being_destroyed) + goto unlock; + tbl = rht_dereference(ht->tbl, ht); if (ht->p.grow_decision && ht->p.grow_decision(ht, tbl->size)) @@ -494,6 +497,7 @@ static void rht_deferred_worker(struct work_struct *work) else if (ht->p.shrink_decision && ht->p.shrink_decision(ht, tbl->size)) rhashtable_shrink(ht); +unlock: mutex_unlock(&ht->mutex); } |