Skip to content
Commit 3ae28ff9 authored by Zhantao Tang's avatar Zhantao Tang
Browse files

drivers: cpypto: hse-rng: make mutex lock/unlock operations balance



The NXP HSE updates its rng driver and add async read support, but
in the async support codes, there is a mutex lock for cached random
data, and it will cause the following issue:

 =====================================
 WARNING: bad unlock balance detected!
 5.10.78-yocto-standard #1 Not tainted
 -------------------------------------
 irq/40-hse-mu0b/144 is trying to release lock (&ctx->req_lock) at:
 [<ffffffc01104027c>] hse_rng_done+0x88/0x9c
 but there are no more locks to release!

 other info that might help us debug this:
 no locks held by irq/40-hse-mu0b/144.

 stack backtrace:
 CPU: 0 PID: 144 Comm: irq/40-hse-mu0b Not tainted 5.10.78-yocto-standard #1
 Hardware name: Freescale S32G274A (DT)
 Call trace:
  dump_backtrace+0x0/0x1d4
  show_stack+0x24/0x30
  dump_stack+0xf0/0x13c
  print_unlock_imbalance_bug.part.0+0xc8/0xdc
  __lock_release+0x158/0x290
  lock_release+0x120/0x2c0
  __mutex_unlock_slowpath+0x6c/0x2d0
  mutex_unlock+0x38/0x60
  hse_rng_done+0x88/0x9c
  hse_srv_rsp_dispatch+0x114/0x270
  hse_rx_dispatcher+0x30/0x60
  irq_thread_fn+0x38/0xa0
  irq_thread+0x224/0x304
  kthread+0x158/0x164
  ret_from_fork+0x10/0x3c

The reason is that, the mutex is first acquired by the hse_rng_refill_cache(),
which is called by hse_rng_read() from userspace, but the mutex_unlock() is in
hse_rng_done() which is called in the threaded irq function hse_rx_dispatcher(),
so the above warning shows. And this patch will fix it.

Signed-off-by: default avatarZhantao Tang <zhantao.tang@windriver.com>
parent a849d3a9
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment