Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7d44d94 authored by Satoru Takeuchi's avatar Satoru Takeuchi Committed by Rusty Russell
Browse files

hw_random: free rng_buffer at module exit



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

Signed-off-by: default avatarSatoru Takeuchi <satoru.takeuchi@gmail.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent aabd6a8f
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -380,6 +380,15 @@ void hwrng_unregister(struct hwrng *rng)
}
}
EXPORT_SYMBOL_GPL(hwrng_unregister);
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_DESCRIPTION("H/W Random Number Generator (RNG) driver");
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");