Sparse reports a warning at lec_priv_walk()
warning: context imbalance in lec_priv_walk() - unexpected unlock
The root cause is the missing annotation at lec_priv_walk()
To fix this, __acquire() and __release() annotations
are added in case conditions are not met.
This only instruct Sparse to shutdown the warning
Add the __acquire(&priv->lec_arp_lock)
Add __release(&priv->lec_arp_lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
net/atm/lec.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 22415bc11878..6070acaa3d5c 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -886,12 +886,18 @@ static void *lec_priv_walk(struct lec_state *state, loff_t *l,
if (!state->locked) {
state->locked = priv;
spin_lock_irqsave(&priv->lec_arp_lock, state->flags);
+ } else {
+ /* annotation for sparse */
+ __acquire(&priv->lec_arp_lock);
}
if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) {
spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags);
state->locked = NULL;
/* Partial state reset for the next time we get called */
state->arp_table = state->misc_table = 0;
+ } else {
+ /* annotation for sparse */
+ __release(&priv->lec_arp_lock);
}
return state->locked;
}
--
2.25.3
On Wed, Apr 29, 2020 at 11:05:28AM +0100, Jules Irenge wrote:
> Sparse reports a warning at lec_priv_walk()
> warning: context imbalance in lec_priv_walk() - unexpected unlock
>
> The root cause is the missing annotation at lec_priv_walk()
> To fix this, __acquire() and __release() annotations
> are added in case conditions are not met.
> This only instruct Sparse to shutdown the warning
>
> Add the __acquire(&priv->lec_arp_lock)
> Add __release(&priv->lec_arp_lock) annotation
At least those two I got should be in one patch. Simple fix all same sparse
issues at once.
--
With Best Regards,
Andy Shevchenko