mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* issue with unreachable code in net sxgbe driver
@ 2021-07-09 14:03 Colin Ian King
  0 siblings, 0 replies; only message in thread
From: Colin Ian King @ 2021-07-09 14:03 UTC (permalink / raw)
  To: Byungho An, Siva Reddy
  Cc: David S. Miller, Jakub Kicinski, linux-kernel, netdev

Hi,

Static analysis with Coverity has detected several occurrences of dead
code in the sxgbe driver in function sxgbe_mtl_init. The issue was
introduced with the following commit:

commit 1edb9ca69e8a7988900fc0283e10550b5592164d
Author: Siva Reddy <siva.kallam@samsung.com>
Date:   Tue Mar 25 12:10:54 2014 -0700

    net: sxgbe: add basic framework for Samsung 10Gb ethernet driver

The analysis is as follows:

 20static void sxgbe_mtl_init(void __iomem *ioaddr, unsigned int etsalg,
 21                           unsigned int raa)
 22{
 23        u32 reg_val;
 24
 25        reg_val = readl(ioaddr + SXGBE_MTL_OP_MODE_REG);
 26        reg_val &= ETS_RST;
 27
 28        /* ETS Algorith */
 29        switch (etsalg & SXGBE_MTL_OPMODE_ESTMASK) {

Logically dead code (DEADCODE)

 30        case ETS_WRR:
 31                reg_val &= ETS_WRR;
 32                break;


Logically dead code (DEADCODE)

 33        case ETS_WFQ:
 34                reg_val |= ETS_WFQ;
 35                break;

Logically dead code (DEADCODE)

 36        case ETS_DWRR:
 37                reg_val |= ETS_DWRR;
 38                break;
 39        }

SXGBE_MTL_OPMODE_ESTMASK is defined as 0x03
ETS_WRR is 0xFFFFFF9F
ETS_WFQ is 0x00000020
ETS_DWRR is 0x00000040

so the masking of etsalg & SXGBE_MTL_OPMODE_ESTMASK will never match any
of the ETS_* values, hence the dead code.


 40        writel(reg_val, ioaddr + SXGBE_MTL_OP_MODE_REG);
 41
 42        switch (raa & SXGBE_MTL_OPMODE_RAAMASK) {

Logically dead code (DEADCODE)

 43        case RAA_SP:
 44                reg_val &= RAA_SP;
 45                break;

Logically dead code (DEADCODE)

 46        case RAA_WSP:
 47                reg_val |= RAA_WSP;
 48                break;
 49        }
 50        writel(reg_val, ioaddr + SXGBE_MTL_OP_MODE_REG);
 51}

SXGBE_MTL_OPMODE_RAAMASK is defined as 0x1
RAA_SP is 0xFFFFFFFB
RAA_WSP is 0x00000004

so masking of raa & SXGBE_MTL_OPMODE_RAAMASK will never match any of the
RAA_* values, hence the dead code.

I don't think this is intentional. Not sure how to fix this hence I'm
reporting this issue.

Regards,

Colin

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-09 14:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-09 14:03 issue with unreachable code in net sxgbe driver Colin Ian King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®