diff options
author | Satoru Takeuchi <satoru.takeuchi@gmail.com> | 2013-03-20 01:58:51 +0100 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-03-20 01:59:37 +0100 |
commit | b7d44d9487a11e835de10908f4ab30b4290c0b7f (patch) | |
tree | 0877897709f09da01e40b55e1329926accd401a8 /drivers/char | |
parent | Revert "virtio_console: Initialize guest_connected=true for rproc_serial" (diff) | |
download | linux-b7d44d9487a11e835de10908f4ab30b4290c0b7f.tar.xz linux-b7d44d9487a11e835de10908f4ab30b4290c0b7f.zip |
hw_random: free rng_buffer at module exit
rng-core module allocates rng_buffer by kmalloc() since commit
f7f154f1246ccc5a0a7e9ce50932627d60a0c878. 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>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hw_random/core.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index 69ae5972713c..a0f7724852eb 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c @@ -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"); |