linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* False positives unlock warning
@ 2015-01-14 13:46 Bastien Nocera
  2015-01-14 14:11 ` Dan Carpenter
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien Nocera @ 2015-01-14 13:46 UTC (permalink / raw)
  To: linux-sparse

Hey,

The following project (a device driver which should compile with kernel
3.17 and above) throws a few false positives with "make C=1":
core/rtw_recv.c:3406:26: warning: context imbalance in 'recv_indicatepkt_reorder' - unexpected unlock
core/rtw_xmit.c:4300:6: warning: context imbalance in 'xmit_delivery_enabled_frames' - wrong count at exit

The code however doesn't look like it's doing anything problematic.

Any ideas?

Cheers


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: False positives unlock warning
  2015-01-14 13:46 False positives unlock warning Bastien Nocera
@ 2015-01-14 14:11 ` Dan Carpenter
  2015-01-14 14:19   ` Bastien Nocera
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2015-01-14 14:11 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-sparse

On Wed, Jan 14, 2015 at 02:46:58PM +0100, Bastien Nocera wrote:
> Hey,
> 
> The following project (a device driver which should compile with kernel
> 3.17 and above) throws a few false positives with "make C=1":
> core/rtw_recv.c:3406:26: warning: context imbalance in 'recv_indicatepkt_reorder' - unexpected unlock
> core/rtw_xmit.c:4300:6: warning: context imbalance in 'xmit_delivery_enabled_frames' - wrong count at exit

This could be either of:

	drivers/staging/rtl8723au/core/rtw_recv.c
	drivers/staging/rtl8188eu/core/rtw_recv.c

Neither one of these give me that warning.  I'm using the latest Sparse
from git and today's linux-next.  Can you give us some more hints what
you're talking about?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: False positives unlock warning
  2015-01-14 14:11 ` Dan Carpenter
@ 2015-01-14 14:19   ` Bastien Nocera
  2015-01-14 16:41     ` Dan Carpenter
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien Nocera @ 2015-01-14 14:19 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-sparse

On Wed, 2015-01-14 at 17:11 +0300, Dan Carpenter wrote:
> On Wed, Jan 14, 2015 at 02:46:58PM +0100, Bastien Nocera wrote:
> > Hey,
> > 
> > The following project (a device driver which should compile with kernel
> > 3.17 and above) throws a few false positives with "make C=1":
> > core/rtw_recv.c:3406:26: warning: context imbalance in 'recv_indicatepkt_reorder' - unexpected unlock
> > core/rtw_xmit.c:4300:6: warning: context imbalance in 'xmit_delivery_enabled_frames' - wrong count at exit
> 
> This could be either of:
> 
> 	drivers/staging/rtl8723au/core/rtw_recv.c
> 	drivers/staging/rtl8188eu/core/rtw_recv.c
> 
> Neither one of these give me that warning.  I'm using the latest Sparse
> from git and today's linux-next.  Can you give us some more hints what
> you're talking about?

Duh. I forgot the link to my repository (which isn't upstream yet, as it
needs cleaning up before submission, including fixing sparse warnings).

This is the code in question:
https://github.com/hadess/rtl8723bs/blob/master/core/rtw_recv.c#L3238
and:
https://github.com/hadess/rtl8723bs/blob/master/core/rtw_xmit.c#L4300

Sorry about that.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: False positives unlock warning
  2015-01-14 14:19   ` Bastien Nocera
@ 2015-01-14 16:41     ` Dan Carpenter
  2015-01-14 17:42       ` Bastien Nocera
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2015-01-14 16:41 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-sparse

Sparse gets confused because of the unused "_success_exit:" label.  If
you delete that it should go away.  In "real" kernel code GCC will warn
about unused labels.

I created a more minimal test case while I was looking at this, if
anyone is interested.

static int foo;

int recv_indicatepkt_reorder(_adapter *padapter, union recv_frame *prframe)
{
        struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
        struct recv_reorder_ctrl *preorder_ctrl = prframe->u.hdr.preorder_ctrl;
        _queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;

        spin_lock(&ppending_recvframe_queue->lock);
        if (foo)
                goto err;
        spin_unlock(&ppending_recvframe_queue->lock);

unused_label:
        return 0;
err:
        spin_unlock(&ppending_recvframe_queue->lock);
        return -1;
}

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: False positives unlock warning
  2015-01-14 16:41     ` Dan Carpenter
@ 2015-01-14 17:42       ` Bastien Nocera
  2015-01-14 20:54         ` Dan Carpenter
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien Nocera @ 2015-01-14 17:42 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-sparse

On Wed, 2015-01-14 at 19:41 +0300, Dan Carpenter wrote:
> Sparse gets confused because of the unused "_success_exit:" label.  If
> you delete that it should go away.  In "real" kernel code GCC will warn
> about unused labels.

Unfortunately, the problem in core/rtw_xmit.c is the same warning, but
this time the label is used.

Cheers


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: False positives unlock warning
  2015-01-14 17:42       ` Bastien Nocera
@ 2015-01-14 20:54         ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2015-01-14 20:54 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-sparse

On Wed, Jan 14, 2015 at 06:42:40PM +0100, Bastien Nocera wrote:
> On Wed, 2015-01-14 at 19:41 +0300, Dan Carpenter wrote:
> > Sparse gets confused because of the unused "_success_exit:" label.  If
> > you delete that it should go away.  In "real" kernel code GCC will warn
> > about unused labels.
> 
> Unfortunately, the problem in core/rtw_xmit.c is the same warning, but
> this time the label is used.

The goto has been ifdeffed out.  Try deleting the "exit:" label.  It
still compiles fine for me and the warning is gone.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-01-14 20:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-14 13:46 False positives unlock warning Bastien Nocera
2015-01-14 14:11 ` Dan Carpenter
2015-01-14 14:19   ` Bastien Nocera
2015-01-14 16:41     ` Dan Carpenter
2015-01-14 17:42       ` Bastien Nocera
2015-01-14 20:54         ` Dan Carpenter

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).