diff mbox series

[6/6] net: atm: Add annotation for lec_priv_walk()

Message ID 20200429100529.19645-7-jbi.octave@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show
Series None | expand

Commit Message

Jules Irenge April 29, 2020, 10:05 a.m. UTC
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 <jbi.octave@gmail.com>
---
 net/atm/lec.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Andy Shevchenko April 29, 2020, 10:22 a.m. UTC | #1
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.
diff mbox series

Patch

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;
 }