summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorSatoru Takeuchi <satoru.takeuchi@gmail.com>2013-03-20 11:28:51 +1030
committerRusty Russell <rusty@rustcorp.com.au>2013-03-20 11:29:37 +1030
commitb7d44d9487a11e835de10908f4ab30b4290c0b7f (patch)
tree0877897709f09da01e40b55e1329926accd401a8 /drivers/char
parentaabd6a8fa5a933bdf968cd86e34122745c1960e8 (diff)
downloadblackbird-op-linux-b7d44d9487a11e835de10908f4ab30b4290c0b7f.tar.gz
blackbird-op-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.c9
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");
OpenPOWER on IntegriCloud