False positives unlock warning
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
Quoted 6 lines · Bastien Nocera
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 unlockcore/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
Quoted 8 lines · Dan Carpenter
Quoted 6 lines · Bastien Nocera
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 unlockcore/rtw_xmit.c:4300:6: warning: context imbalance in 'xmit_delivery_enabled_frames' - wrong count at exit
Quoted 8 lines
This could be either of:
drivers/staging/rtl8723au/core/rtw_recv.c
drivers/staging/rtl8188eu/core/rtw_recv.cNeither 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.
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
Quoted 3 lines · Dan Carpenter
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
Quoted 7 lines · Bastien Nocera
Quoted 3 lines · Dan Carpenter
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.cis 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