netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
  • * [PATCH v2] net: atm: Add annotation for lec_priv_walk() and lec_seq_stop()
           [not found] <0/6>
           [not found] ` <20200429100529.19645-1-jbi.octave@gmail.com>
    @ 2020-04-29 14:58 ` Jules Irenge
      1 sibling, 0 replies; 6+ messages in thread
    From: Jules Irenge @ 2020-04-29 14:58 UTC (permalink / raw)
      To: linux-kernel
      Cc: David S. Miller, Jakub Kicinski, Andy Shevchenko,
    	Michael S. Tsirkin, Greg Kroah-Hartman, Thomas Gleixner,
    	Dan Carpenter, open list:NETWORKING [GENERAL]
    
    Sparse reports a warning at lec_priv_walk() and lec_seq_stop()
    
    warning: context imbalance in lec_priv_walk() - unexpected unlock
    warning: context imbalance in lec_seq_stop() - unexpected unlock
    
    The root cause is the missing annotation at lec_priv_walk()
    	and lec_seq_stop()
    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
    Add __releases(&state->locked->lec_arp_lock) annotation
    Add  __release(&state->locked->lec_arp_lock) annotation
    
    Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
    ---
    Changes since v2 
    - merge patch No 6 and No 4 into one
    
     net/atm/lec.c | 10 ++++++++++
     1 file changed, 10 insertions(+)
    
    diff --git a/net/atm/lec.c b/net/atm/lec.c
    index 25fa3a7b72bd..7947abb17af2 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;
     }
    @@ -940,6 +946,7 @@ static void *lec_seq_start(struct seq_file *seq, loff_t *pos)
     }
     
     static void lec_seq_stop(struct seq_file *seq, void *v)
    +	__releases(&state->locked->lec_arp_lock)
     {
     	struct lec_state *state = seq->private;
     
    @@ -947,6 +954,9 @@ static void lec_seq_stop(struct seq_file *seq, void *v)
     		spin_unlock_irqrestore(&state->locked->lec_arp_lock,
     				       state->flags);
     		dev_put(state->dev);
    +	} else {
    +		/* annotation for sparse */
    +		__release(&state->locked->lec_arp_lock);
     	}
     }
     
    -- 
    2.25.3
    
    
    ^ permalink raw reply related	[flat|nested] 6+ messages in thread

  • end of thread, other threads:[~2020-04-29 15:00 UTC | newest]
    
    Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
    -- links below jump to the message on this page --
         [not found] <0/6>
         [not found] ` <20200429100529.19645-1-jbi.octave@gmail.com>
    2020-04-29 10:05   ` [PATCH 2/6] udp: Add missing annotations for busylock_acquire() and busylock_release() Jules Irenge
    2020-04-29 10:05   ` [PATCH 3/6] udp: Add annotations for udp_rmem_release() Jules Irenge
    2020-04-29 10:05   ` [PATCH 4/6] net: atm: Add missing annotation for lec_seq_stop() Jules Irenge
    2020-04-29 10:05   ` [PATCH 6/6] net: atm: Add annotation for lec_priv_walk() Jules Irenge
    2020-04-29 10:22     ` Andy Shevchenko
    2020-04-29 14:58 ` [PATCH v2] net: atm: Add annotation for lec_priv_walk() and lec_seq_stop() Jules Irenge
    

    This is a public inbox, see mirroring instructions
    for how to clone and mirror all data and code used for this inbox;
    as well as URLs for NNTP newsgroup(s).