Skip to content

Commit

Permalink
hw_random: free rng_buffer at module exit
Browse files Browse the repository at this point in the history
rng-core module allocates rng_buffer by kmalloc() since commit
f7f154f. 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>
  • Loading branch information
Satoru Takeuchi authored and Rusty Russell committed Mar 20, 2013
1 parent aabd6a8 commit b7d44d9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/char/hw_random/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

0 comments on commit b7d44d9

Please sign in to comment.