lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <7e9fbad4-d040-409c-a4d2-24e9929e63ba@stanley.mountain>
Date: Wed, 24 Jul 2024 11:11:43 -0500
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Raghu Vatsavayi <rvatsavayi@...iumnetworks.com>
Cc: netdev@...r.kernel.org
Subject: [bug report] liquidio: ethtool and led control support

Hello Raghu Vatsavayi,

Commit dc3abcbeaeb9 ("liquidio: ethtool and led control support")
from Sep 1, 2016 (linux-next), leads to the following Smatch static
checker warning:

	drivers/net/ethernet/cavium/liquidio/lio_ethtool.c:2721 cn23xx_read_csr_reg()
	warn: reusing outside iterator: 'i'

drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
    2706         /*0x100b0*/
    2707         for (i = 0; i < CN23XX_MAX_OUTPUT_QUEUES; i++) {
    2708                 reg = CN23XX_SLI_OQ_PKTS_SENT(i);
    2709                 len += sprintf(s + len, "\n[%08x] (SLI_PKT%d_CNTS): %016llx\n",
    2710                                reg, i, (u64)octeon_read_csr64(oct, reg));
    2711         }
    2712 
    2713         /*0x100c0*/
    2714         for (i = 0; i < CN23XX_MAX_OUTPUT_QUEUES; i++) {

You would think this would loop 64 times, but it only loops once

    2715                 reg = 0x100c0 + i * CN23XX_OQ_OFFSET;
    2716                 len += sprintf(s + len,
    2717                                "\n[%08x] (SLI_PKT%d_ERROR_INFO): %016llx\n",
    2718                                reg, i, (u64)octeon_read_csr64(oct, reg));
    2719 
    2720                 /*0x10000*/
--> 2721                 for (i = 0; i < CN23XX_MAX_INPUT_QUEUES; i++) {

Because these inside loops re-use i and end with i == 64.

    2722                         reg = CN23XX_SLI_IQ_PKT_CONTROL64(i);
    2723                         len += sprintf(
    2724                                 s + len,
    2725                                 "\n[%08x] (SLI_PKT%d_INPUT_CONTROL): %016llx\n",
    2726                                 reg, i, (u64)octeon_read_csr64(oct, reg));
    2727                 }
    2728 
    2729                 /*0x10010*/
    2730                 for (i = 0; i < CN23XX_MAX_INPUT_QUEUES; i++) {

Etc..

    2731                         reg = CN23XX_SLI_IQ_BASE_ADDR64(i);
    2732                         len += sprintf(
    2733                             s + len,
    2734                             "\n[%08x] (SLI_PKT%d_INSTR_BADDR): %016llx\n", reg,
    2735                             i, (u64)octeon_read_csr64(oct, reg));
    2736                 }
    2737 
    2738                 /*0x10020*/
    2739                 for (i = 0; i < CN23XX_MAX_INPUT_QUEUES; i++) {
    2740                         reg = CN23XX_SLI_IQ_DOORBELL(i);
    2741                         len += sprintf(
    2742                             s + len,
    2743                             "\n[%08x] (SLI_PKT%d_INSTR_BAOFF_DBELL): %016llx\n",
    2744                             reg, i, (u64)octeon_read_csr64(oct, reg));
    2745                 }
    2746 
    2747                 /*0x10030*/
    2748                 for (i = 0; i < CN23XX_MAX_INPUT_QUEUES; i++) {
    2749                         reg = CN23XX_SLI_IQ_SIZE(i);
    2750                         len += sprintf(
    2751                             s + len,
    2752                             "\n[%08x] (SLI_PKT%d_INSTR_FIFO_RSIZE): %016llx\n",
    2753                             reg, i, (u64)octeon_read_csr64(oct, reg));
    2754                 }
    2755 
    2756                 /*0x10040*/
    2757                 for (i = 0; i < CN23XX_MAX_INPUT_QUEUES; i++)
    2758                         reg = CN23XX_SLI_IQ_INSTR_COUNT64(i);
    2759                 len += sprintf(s + len,
    2760                                "\n[%08x] (SLI_PKT_IN_DONE%d_CNTS): %016llx\n",
    2761                                reg, i, (u64)octeon_read_csr64(oct, reg));
    2762         }
    2763 
    2764         return len;
    2765 }

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ