Bug 98231

Summary: Suspected bug in drivers/atm/iphase.c: function ‘rx_pkt’ (misleading indentation)
Product: Drivers Reporter: Dave Malcolm (dmalcolm)
Component: PCIAssignee: drivers_pci (drivers_pci)
Status: NEW ---    
Severity: normal CC: 3chas3
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.0.3 Subsystem:
Regression: No Bisected commit-id:

Description Dave Malcolm 2015-05-13 17:46:54 UTC
This code (in linux-4.0.3) in drivers/atm/iphase.c: function "rx_pkt" looks dubious:
        if (!(skb = atm_alloc_charge(vcc, len, GFP_ATOMIC))) {
           if (vcc->vci < 32)
              printk("Drop control packets\n");
	      goto out_free_desc;
        }

Is the "goto out_free_desc;" meant to be guarded by the "if (vcc->vci < 32)" clause?  It isn't - does that inner "if" need braces?  Alternatively, should the "goto" statement's indentation match that of the inner "if"?

Seen via an experimental new gcc warning for gcc 6, -Wmisleading-indentation, using gcc r223098 adding -Werror=misleading-indentation" to KBUILD_CFLAGS in Makefile, where the experimental gcc emits this error:

drivers/atm/iphase.c: In function ‘rx_pkt’:
drivers/atm/iphase.c:1178:8: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
        goto out_free_desc;
        ^
drivers/atm/iphase.c:1176:12: note: ...this ‘if’ clause, but it is not
            if (vcc->vci < 32)
Comment 1 Chas Williams 2015-05-14 10:21:40 UTC
The code is right and the indent is wrong.

Cells on VCI < 32 are typically part of some control channel, like signalling.  Dropping this traffic is "bad" so an attempt was made to warn the user about this.  In all cases, you need to go to out_free_desc.  This code also probably predates the net_ratelimit() et al.