Bug 188681 - Function csio_hw_flash_erase_sectors() does not return correct error codes on failures
Summary: Function csio_hw_flash_erase_sectors() does not return correct error codes on...
Status: NEW
Alias: None
Product: SCSI Drivers
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: scsi_drivers-other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-25 10:48 UTC by bianpan
Modified: 2016-11-25 10:48 UTC (History)
0 users

See Also:
Kernel Version: linux-4.9-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description bianpan 2016-11-25 10:48:22 UTC
From the usages of function csio_hw_flash_erase_sectors() defined in drivers/scsi/csiostor/csio_hw.c, we can infer that it should return a non-zero error code when something goes wrong. However, it will return 0 even the calls to csio_hw_sf1_write() or csio_hw_flash_wait_op() fails. Maybe it is better to use "return ret;" instead of "return 0;" at line 616. Codes related to this bug are summarised as follows.

csio_hw_flash_erase_sectors @@ drivers/scsi/csiostor/csio_hw.c
 589 static int
 590 csio_hw_flash_erase_sectors(struct csio_hw *hw, int32_t start, int32_t end)
 591 {
 592     int ret = 0;
 593 
 594     while (start <= end) {
 595 
 596         ret = csio_hw_sf1_write(hw, 1, 0, 1, SF_WR_ENABLE);
 597         if (ret != 0)
 598             goto out;
 599 
 600         ret = csio_hw_sf1_write(hw, 4, 0, 1,
 601                     SF_ERASE_SECTOR | (start << 8));
 602         if (ret != 0)
 603             goto out;
 604 
 605         ret = csio_hw_flash_wait_op(hw, 14, 500);
 606         if (ret != 0)
 607             goto out;
 608 
 609         start++;
 610     }
 611 out:
 612     if (ret)
 613         csio_err(hw, "erase of flash sector %d failed, error %d\n",
 614              start, ret);
 615     csio_wr_reg32(hw, 0, SF_OP_A);    /* unlock SF */
 616     return 0;          // return ret?
 617 }

csio_hw_fw_dload @@ drivers/scsi/csiostor/csio_hw.c
 667 static int
 668 csio_hw_fw_dload(struct csio_hw *hw, uint8_t *fw_data, uint32_t size)
 669 {
         ...
 719     ret = csio_hw_flash_erase_sectors(hw, FLASH_FW_START_SEC,
 720                       FLASH_FW_START_SEC + i - 1);
 721     if (ret) {           // check the return value of csio_hw_flash_erase_sectors()
 722         csio_err(hw, "Flash Erase failed\n");
 723         goto out;
 724     }
         ...
 755 out:
 756     if (ret)
 757         csio_err(hw, "firmware download failed, error %d\n", ret);
 758     return ret;
 759 }

Thanks very much!

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