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

Commit 64f0f97c authored by Neeraj Soni's avatar Neeraj Soni
Browse files

rng: lock global variable before accessing.



Changes done to lock mutex before accessing global variable
to avoid any race condition.

Change-Id: Ia32ab856b4d3a2326c1b004341b40d72b81c5d5b
Signed-off-by: default avatarNeeraj Soni <neersoni@codeaurora.org>
parent f762adc5
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -346,8 +346,12 @@ static int hwrng_fillfn(void *unused)
	long rc;

	while (!kthread_should_stop()) {
		if (!current_rng)
		mutex_lock(&rng_mutex);
		if (!current_rng) {
			mutex_unlock(&rng_mutex);
			break;
		}
		mutex_unlock(&rng_mutex);
		rc = rng_get_data(current_rng, rng_fillbuf,
				  rng_buffer_size(), 1);
		if (rc <= 0) {