Project

General

Profile

Actions

Bug #14394

closed

emlxs: array subscript is partly outside array bounds

Added by Toomas Soome over 1 year ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

Build errors with gcc 11:

    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c: In function 'emlxs_sli3_hba_reset':
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:2091:22: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     2091 |                 swpmb->mbxCommand = MBX_RESTART;
          |                      ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:2036:18: note: while referencing 'word0'
     2036 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:2092:22: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     2092 |                 swpmb->mbxHc = 1;
          |                      ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:2036:18: note: while referencing 'word0'
     2036 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c: In function 'emlxs_sli3_issue_mbox_cmd':
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:3449:30: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     3449 |                 while ((swpmb->mbxOwner == OWN_CHIP) &&
          |                              ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:3158:33: note: while referencing 'word0'
     3158 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:3492:27: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     3492 |                 if ((swpmb->mbxCommand == MBX_CONFIG_PORT) &&
          |                           ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:3158:33: note: while referencing 'word0'
     3158 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:3493:27: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     3493 |                     (swpmb->mbxStatus == MBX_SUCCESS)) {
          |                           ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:3158:33: note: while referencing 'word0'
     3158 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c: In function 'emlxs_sli3_hba_kill':
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5512:14: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     5512 |         swpmb->mbxCommand = MBX_KILL_BOARD;
          |              ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5449:18: note: while referencing 'word0'
     5449 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5513:14: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     5513 |         swpmb->mbxOwner = OWN_CHIP;
          |              ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5449:18: note: while referencing 'word0'
     5449 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5555:34: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     5555 |                         if (swpmb->mbxOwner == 0) {
          |                                  ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5449:18: note: while referencing 'word0'
     5449 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5582:14: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     5582 |         swpmb->mbxCommand = MBX_KILL_BOARD;
          |              ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5449:18: note: while referencing 'word0'
     5449 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5583:14: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     5583 |         swpmb->mbxOwner = OWN_CHIP;
          |              ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5449:18: note: while referencing 'word0'
     5449 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5610:34: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     5610 |                         if (swpmb->mbxOwner == 0) {
          |                                  ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5449:18: note: while referencing 'word0'
     5449 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c: In function 'emlxs_sli3_hba_kill4quiesce':
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5701:14: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     5701 |         swpmb->mbxCommand = MBX_KILL_BOARD;
          |              ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5684:18: note: while referencing 'word0'
     5684 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5702:14: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     5702 |         swpmb->mbxOwner = OWN_CHIP;
          |              ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5684:18: note: while referencing 'word0'
     5684 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5741:34: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     5741 |                         if (swpmb->mbxOwner == 0) {
          |                                  ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5684:18: note: while referencing 'word0'
     5684 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c: In function 'emlxs_handle_mb_event':
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5869:21: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     5869 |         while (swpmb->mbxOwner == OWN_CHIP) {
          |                     ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5781:33: note: while referencing 'word0'
     5781 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5952:26: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     5952 |                 if (swpmb->mbxCommand != MBX_DOWN_LOAD &&
          |                          ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5781:33: note: while referencing 'word0'
     5781 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5953:26: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     5953 |                     swpmb->mbxCommand != MBX_DUMP_MEMORY) {
          |                          ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5781:33: note: while referencing 'word0'
     5781 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5957:34: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     5957 |                             swpmb->mbxStatus);
          |                                  ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5781:33: note: while referencing 'word0'
     5781 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5956:53: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     5956 |                             emlxs_mb_cmd_xlate(swpmb->mbxCommand),
          |                                                     ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5781:33: note: while referencing 'word0'
     5781 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5944:26: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     5944 |                 if (swpmb->mbxCommand != MBX_DOWN_LOAD &&
          |                          ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5781:33: note: while referencing 'word0'
     5781 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5945:26: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     5945 |                     swpmb->mbxCommand != MBX_DUMP_MEMORY) {
          |                          ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5781:33: note: while referencing 'word0'
     5781 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5949:34: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     5949 |                             swpmb->mbxStatus);
          |                                  ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5781:33: note: while referencing 'word0'
     5781 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5948:53: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     5948 |                             emlxs_mb_cmd_xlate(swpmb->mbxCommand),
          |                                                     ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5781:33: note: while referencing 'word0'
     5781 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5874:34: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     5874 |                             MAILBOX->mbxStatus);
          |                                  ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5781:33: note: while referencing 'word0'
     5781 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5873:53: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'volatile uint32_t[1]' {aka 'volatile unsigned int[1]'} [-Werror=array-bounds]
     5873 |                             emlxs_mb_cmd_xlate(swpmb->mbxCommand),
          |                                                     ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:5781:33: note: while referencing 'word0'
     5781 |         volatile uint32_t       word0;
          |                                 ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c: In function 'emlxs_sli3_timer_check_mbox':
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:6066:23: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     6066 |                 if (mb->mbxOwner == OWN_HOST) {
          |                       ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:6014:18: note: while referencing 'word0'
     6014 |         uint32_t word0;
          |                  ^~~~~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:6073:65: error: array subscript 'MAILBOX[0]' is partly outside array bounds of 'uint32_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     6073 |                             "hc=%x ha=%x", emlxs_mb_cmd_xlate(mb->mbxCommand),
          |                                                                 ^~
    ../../common/io/fibre-channel/fca/emlxs/emlxs_sli3.c:6014:18: note: while referencing 'word0'
     6014 |         uint32_t word0;
          |                  ^~~~~
    cc1: all warnings being treated as errors

change word0 to pointer and allocate memory with swpmb; this way we do have fully allocated mailbox structure and we can use pointer to uint32_t to store values.

Testing done: build/install/boot, but I do not have emulex+fc infrastructure available at this time.

Also tested by Carsten Grzemba:

I did some tests and see no issues:
Apr 28 09:49:57 test01 emlxs: [ID 349649 kern.info] [ B.0682]emlxs0: NOTICE: 720: Link up. (8Gb, fabric, initiator)
Apr 28 09:50:01 test01 emlxs: [ID 349649 kern.info] [ B.1AC8]emlxs1: NOTICE: 100: Driver attach. (EMLXS s11-64 i386 v2.80.8.0 (2020.02.28.28.16))
Apr 28 09:50:01 test01 emlxs: [ID 349649 kern.info] [ B.1ACB]emlxs1: NOTICE: 100: Driver attach. (LPe12002-M8 Ven_id:10df Dev_id:f100 Sub_id:f100 Id:34)
Apr 28 09:50:01 test01 emlxs: [ID 349649 kern.info] [ B.1AD2]emlxs1: NOTICE: 100: Driver attach. (Firmware:2.02a3 (U3D2.02A3) Boot:7.00x2)
Apr 28 09:50:01 test01 emlxs: [ID 349649 kern.info] [ B.1B0D]emlxs1: NOTICE: 100: Driver attach. (SLI:3 MSIX:8 NPIV:0 FCA)
Apr 28 09:50:01 test01 emlxs: [ID 349649 kern.info] [ B.1B15]emlxs1: NOTICE: 100: Driver attach. (WWPN:100000109B4D6D8B WWNN:200000109B4D6D8B)

Dtrace shows me that emlxs_sli3_issue_mbox_cmd and emlxs_sli3_timer_check_mbox was actually used.

Actions #1

Updated by Electric Monk over 1 year ago

  • Gerrit CR set to 1942
Actions #2

Updated by Toomas Soome over 1 year ago

  • Description updated (diff)
Actions #3

Updated by Toomas Soome over 1 year ago

  • Description updated (diff)
Actions #4

Updated by Toomas Soome 5 months ago

  • Description updated (diff)
  • Status changed from In Progress to Pending RTI
Actions #5

Updated by Electric Monk 5 months ago

  • Status changed from Pending RTI to Closed
  • % Done changed from 90 to 100

git commit cf7391a51241c3aef924a259e741f0df84659191

commit  cf7391a51241c3aef924a259e741f0df84659191
Author: Toomas Soome <tsoome@me.com>
Date:   2023-04-29T15:35:00.000Z

    14394 emlxs: array subscript is partly outside array bounds
    Reviewed by: Garrett D'Amore <garrett@damore.org>
    Reviewed by: Carsten Grzemba <grzemba@contac-dt.de>
    Approved by: Dan McDonald <danmcd@mnx.io>

Actions

Also available in: Atom PDF