Skip to content

Commit

Permalink
hwrng: move some code out mutex_lock for avoiding underlying deadlock
Browse files Browse the repository at this point in the history
In next patch, we use reference counting for each struct hwrng,
changing reference count also needs to take mutex_lock. Before
releasing the lock, if we try to stop a kthread that waits to
take the lock to reduce the referencing count, deadlock will
occur.

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Amos Kong authored and Herbert Xu committed Dec 22, 2014
1 parent 9372b35 commit 1dacb39
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/char/hw_random/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,12 @@ void hwrng_unregister(struct hwrng *rng)
}
}
if (list_empty(&rng_list)) {
mutex_unlock(&rng_mutex);
unregister_miscdev();
if (hwrng_fill)
kthread_stop(hwrng_fill);
}

mutex_unlock(&rng_mutex);
} else
mutex_unlock(&rng_mutex);
}
EXPORT_SYMBOL_GPL(hwrng_unregister);

Expand Down

0 comments on commit 1dacb39

Please sign in to comment.