hwspinlock: rockchip: object to unlocking someone else's lock

Check hwlock user id and object to unlocking someone else's lock
when invoking unlock() API.

Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: I46c256fd703fa56ce3d175ff2d721f53d3615ec0
This commit is contained in:
Frank Wang
2024-01-11 15:15:39 +08:00
parent 3229c7d5d5
commit 99111d8fb2

View File

@@ -45,6 +45,14 @@ static int rockchip_hwspinlock_trylock(struct hwspinlock *lock)
static void rockchip_hwspinlock_unlock(struct hwspinlock *lock)
{
void __iomem *lock_addr = lock->priv;
u32 lock_owner = readl(lock_addr) & HWSPINLOCK_ID_MASK;
if (lock_owner != hwlock_user_id) {
dev_warn(lock->bank->dev,
"WARNING: against user %u release a lock held by %u\n",
hwlock_user_id, lock_owner);
return;
}
/* Release the lock by writing 0 to it */
writel(0, lock_addr);