Thread (2 messages) 2 messages, 2 authors, 2020-04-29
STALE2265d
Revisions (2)
  1. v1 [diff vs current]
  2. v1 current

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

From: Jules Irenge <hidden>
Date: 2020-04-29 10:07:02
Also in: lkml
Subsystem: atm, networking [general], the rest · Maintainers: Chas Williams, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help