Bug 98231 - Suspected bug in drivers/atm/iphase.c: function ‘rx_pkt’ (misleading indentation)
Summary: Suspected bug in drivers/atm/iphase.c: function ‘rx_pkt’ (misleading indentat...
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: PCI (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_pci@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-13 17:46 UTC by Dave Malcolm
Modified: 2015-05-14 10:21 UTC (History)
1 user (show)

See Also:
Kernel Version: 4.0.3
Subsystem:
Regression: No
Bisected commit-id:


Attachments

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.

Note You need to log in before you can comment on or make changes to this bug.