Skip to content

Commit

Permalink
hwspinlock: Remove BUG_ON() from the hwspinlock core
Browse files Browse the repository at this point in the history
The original code use BUG_ON() to validate the parameters when locking
or unlocking one hardware lock, but we should not crash the whole kernel
though the hwlock parameters are incorrect, instead we can return
the error number for users and give some warning.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
  • Loading branch information
wangbaolin719 authored and andersson committed Nov 9, 2019
1 parent b674a30 commit b2547dc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/hwspinlock/hwspinlock_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ int __hwspin_trylock(struct hwspinlock *hwlock, int mode, unsigned long *flags)
{
int ret;

BUG_ON(!hwlock);
BUG_ON(!flags && mode == HWLOCK_IRQSTATE);
if (WARN_ON(!hwlock || (!flags && mode == HWLOCK_IRQSTATE)))
return -EINVAL;

/*
* This spin_lock{_irq, _irqsave} serves three purposes:
Expand Down Expand Up @@ -264,8 +264,8 @@ EXPORT_SYMBOL_GPL(__hwspin_lock_timeout);
*/
void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags)
{
BUG_ON(!hwlock);
BUG_ON(!flags && mode == HWLOCK_IRQSTATE);
if (WARN_ON(!hwlock || (!flags && mode == HWLOCK_IRQSTATE)))
return;

/*
* We must make sure that memory operations (both reads and writes),
Expand Down

0 comments on commit b2547dc

Please sign in to comment.