hw_random: free rng_buffer at module exit

rng-core module allocates rng_buffer by kmalloc() since commit
f7f154f124. But this buffer won't be
freed and there is a memory leak possibility at module exit.

Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Satoru Takeuchi 2013-03-20 11:28:51 +10:30 committed by Rusty Russell
parent aabd6a8fa5
commit b7d44d9487
1 changed files with 9 additions and 0 deletions

View File

@ -380,6 +380,15 @@ void hwrng_unregister(struct hwrng *rng)
}
EXPORT_SYMBOL_GPL(hwrng_unregister);
static void __exit hwrng_exit(void)
{
mutex_lock(&rng_mutex);
BUG_ON(current_rng);
kfree(rng_buffer);
mutex_unlock(&rng_mutex);
}
module_exit(hwrng_exit);
MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver");
MODULE_LICENSE("GPL");