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

Commit 1dacb395 authored by Amos Kong's avatar Amos Kong Committed by Herbert Xu
Browse files

hwrng: move some code out mutex_lock for avoiding underlying deadlock



In next patch, we use reference counting for each struct hwrng,
changing reference count also needs to take mutex_lock. Before
releasing the lock, if we try to stop a kthread that waits to
take the lock to reduce the referencing count, deadlock will
occur.

Signed-off-by: default avatarAmos Kong <akong@redhat.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 9372b35e
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -470,11 +470,11 @@ void hwrng_unregister(struct hwrng *rng)
		}
		}
	}
	}
	if (list_empty(&rng_list)) {
	if (list_empty(&rng_list)) {
		mutex_unlock(&rng_mutex);
		unregister_miscdev();
		unregister_miscdev();
		if (hwrng_fill)
		if (hwrng_fill)
			kthread_stop(hwrng_fill);
			kthread_stop(hwrng_fill);
	}
	} else

		mutex_unlock(&rng_mutex);
		mutex_unlock(&rng_mutex);
}
}
EXPORT_SYMBOL_GPL(hwrng_unregister);
EXPORT_SYMBOL_GPL(hwrng_unregister);