Hi zhengbin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mkp-scsi/for-next]
[cannot apply to v5.4-rc4 next-20191018]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    
https://github.com/0day-ci/linux/commits/zhengbin/scsi-core-fix-uninit-value-access-of-variable-sshdr/20191021-160007
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.4.0
reproduce:
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <l...@intel.com>

All errors (new ones prefixed by >>):

   In file included from drivers/scsi/device_handler/scsi_dh_hp_sw.c:13:0:
   drivers/scsi/device_handler/scsi_dh_hp_sw.c: In function 'hp_sw_start_stop':
>> drivers/scsi/device_handler/scsi_dh_hp_sw.c:132:19: error: 'result' 
>> undeclared (first use in this function); did you mean 'res'?
      if (driver_byte(result) != DRIVER_SENSE ||
                      ^
   include/scsi/scsi.h:213:32: note: in definition of macro 'driver_byte'
    #define driver_byte(result) (((result) >> 24) & 0xff)
                                   ^~~~~~
   drivers/scsi/device_handler/scsi_dh_hp_sw.c:132:19: note: each undeclared 
identifier is reported only once for each function it appears in
      if (driver_byte(result) != DRIVER_SENSE ||
                      ^
   include/scsi/scsi.h:213:32: note: in definition of macro 'driver_byte'
    #define driver_byte(result) (((result) >> 24) & 0xff)
                                   ^~~~~~

vim +132 drivers/scsi/device_handler/scsi_dh_hp_sw.c

  > 13  #include <scsi/scsi.h>
    14  #include <scsi/scsi_dbg.h>
    15  #include <scsi/scsi_eh.h>
    16  #include <scsi/scsi_dh.h>
    17  
    18  #define HP_SW_NAME                      "hp_sw"
    19  
    20  #define HP_SW_TIMEOUT                   (60 * HZ)
    21  #define HP_SW_RETRIES                   3
    22  
    23  #define HP_SW_PATH_UNINITIALIZED        -1
    24  #define HP_SW_PATH_ACTIVE               0
    25  #define HP_SW_PATH_PASSIVE              1
    26  
    27  struct hp_sw_dh_data {
    28          int path_state;
    29          int retries;
    30          int retry_cnt;
    31          struct scsi_device *sdev;
    32  };
    33  
    34  static int hp_sw_start_stop(struct hp_sw_dh_data *);
    35  
    36  /*
    37   * tur_done - Handle TEST UNIT READY return status
    38   * @sdev: sdev the command has been sent to
    39   * @errors: blk error code
    40   *
    41   * Returns SCSI_DH_DEV_OFFLINED if the sdev is on the passive path
    42   */
    43  static int tur_done(struct scsi_device *sdev, struct hp_sw_dh_data *h,
    44                      struct scsi_sense_hdr *sshdr)
    45  {
    46          int ret = SCSI_DH_IO;
    47  
    48          switch (sshdr->sense_key) {
    49          case UNIT_ATTENTION:
    50                  ret = SCSI_DH_IMM_RETRY;
    51                  break;
    52          case NOT_READY:
    53                  if (sshdr->asc == 0x04 && sshdr->ascq == 2) {
    54                          /*
    55                           * LUN not ready - Initialization command 
required
    56                           *
    57                           * This is the passive path
    58                           */
    59                          h->path_state = HP_SW_PATH_PASSIVE;
    60                          ret = SCSI_DH_OK;
    61                          break;
    62                  }
    63                  /* Fallthrough */
    64          default:
    65                  sdev_printk(KERN_WARNING, sdev,
    66                             "%s: sending tur failed, sense %x/%x/%x\n",
    67                             HP_SW_NAME, sshdr->sense_key, sshdr->asc,
    68                             sshdr->ascq);
    69                  break;
    70          }
    71          return ret;
    72  }
    73  
    74  /*
    75   * hp_sw_tur - Send TEST UNIT READY
    76   * @sdev: sdev command should be sent to
    77   *
    78   * Use the TEST UNIT READY command to determine
    79   * the path state.
    80   */
    81  static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
    82  {
    83          unsigned char cmd[6] = { TEST_UNIT_READY };
    84          struct scsi_sense_hdr sshdr;
    85          int ret = SCSI_DH_OK, res;
    86          u64 req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
    87                  REQ_FAILFAST_DRIVER;
    88  
    89  retry:
    90          res = scsi_execute(sdev, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
    91                          HP_SW_TIMEOUT, HP_SW_RETRIES, req_flags, 0, 
NULL);
    92          if (res) {
    93                  if (driver_byte(res) == DRIVER_SENSE &&
    94                      scsi_sense_valid(&sshdr))
    95                          ret = tur_done(sdev, h, &sshdr);
    96                  else {
    97                          sdev_printk(KERN_WARNING, sdev,
    98                                      "%s: sending tur failed with %x\n",
    99                                      HP_SW_NAME, res);
   100                          ret = SCSI_DH_IO;
   101                  }
   102          } else {
   103                  h->path_state = HP_SW_PATH_ACTIVE;
   104                  ret = SCSI_DH_OK;
   105          }
   106          if (ret == SCSI_DH_IMM_RETRY)
   107                  goto retry;
   108  
   109          return ret;
   110  }
   111  
   112  /*
   113   * hp_sw_start_stop - Send START STOP UNIT command
   114   * @sdev: sdev command should be sent to
   115   *
   116   * Sending START STOP UNIT activates the SP.
   117   */
   118  static int hp_sw_start_stop(struct hp_sw_dh_data *h)
   119  {
   120          unsigned char cmd[6] = { START_STOP, 0, 0, 0, 1, 0 };
   121          struct scsi_sense_hdr sshdr;
   122          struct scsi_device *sdev = h->sdev;
   123          int res, rc = SCSI_DH_OK;
   124          int retry_cnt = HP_SW_RETRIES;
   125          u64 req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
   126                  REQ_FAILFAST_DRIVER;
   127  
   128  retry:
   129          res = scsi_execute(sdev, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
   130                          HP_SW_TIMEOUT, HP_SW_RETRIES, req_flags, 0, 
NULL);
   131          if (res) {
 > 132                  if (driver_byte(result) != DRIVER_SENSE ||
   133                      !scsi_sense_valid(&sshdr)) {
   134                          sdev_printk(KERN_WARNING, sdev,
   135                                      "%s: sending start_stop_unit 
failed, "
   136                                      "no sense available\n", HP_SW_NAME);
   137                          return SCSI_DH_IO;
   138                  }
   139                  switch (sshdr.sense_key) {
   140                  case NOT_READY:
   141                          if (sshdr.asc == 0x04 && sshdr.ascq == 3) {
   142                                  /*
   143                                   * LUN not ready - manual intervention 
required
   144                                   *
   145                                   * Switch-over in progress, retry.
   146                                   */
   147                                  if (--retry_cnt)
   148                                          goto retry;
   149                                  rc = SCSI_DH_RETRY;
   150                                  break;
   151                          }
   152                          /* fall through */
   153                  default:
   154                          sdev_printk(KERN_WARNING, sdev,
   155                                      "%s: sending start_stop_unit 
failed, "
   156                                      "sense %x/%x/%x\n", HP_SW_NAME,
   157                                      sshdr.sense_key, sshdr.asc, 
sshdr.ascq);
   158                          rc = SCSI_DH_IO;
   159                  }
   160          }
   161          return rc;
   162  }
   163  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip

Reply via email to