diff options
author | Varun Prakash <varun@chelsio.com> | 2018-08-11 11:33:58 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2018-08-27 12:26:10 -0400 |
commit | 89809b028b6f54187b7d81a0c69b35d394c52e62 (patch) | |
tree | 4c089427aab1741ca7c2299def4c9834b014a138 | |
parent | a7ccd92c8d2ac4eb168b621e086be2dc9b8344f6 (diff) |
scsi: csiostor: add a check for NULL pointer after kmalloc()
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/csiostor/csio_hw.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c index 23d07e9f87d0..6ff7c5580fcb 100644 --- a/drivers/scsi/csiostor/csio_hw.c +++ b/drivers/scsi/csiostor/csio_hw.c | |||
@@ -2364,8 +2364,8 @@ bye: | |||
2364 | } | 2364 | } |
2365 | 2365 | ||
2366 | /* | 2366 | /* |
2367 | * Returns -EINVAL if attempts to flash the firmware failed | 2367 | * Returns -EINVAL if attempts to flash the firmware failed, |
2368 | * else returns 0, | 2368 | * -ENOMEM if memory allocation failed else returns 0, |
2369 | * if flashing was not attempted because the card had the | 2369 | * if flashing was not attempted because the card had the |
2370 | * latest firmware ECANCELED is returned | 2370 | * latest firmware ECANCELED is returned |
2371 | */ | 2371 | */ |
@@ -2393,6 +2393,13 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset) | |||
2393 | return -EINVAL; | 2393 | return -EINVAL; |
2394 | } | 2394 | } |
2395 | 2395 | ||
2396 | /* allocate memory to read the header of the firmware on the | ||
2397 | * card | ||
2398 | */ | ||
2399 | card_fw = kmalloc(sizeof(*card_fw), GFP_KERNEL); | ||
2400 | if (!card_fw) | ||
2401 | return -ENOMEM; | ||
2402 | |||
2396 | if (csio_is_t5(pci_dev->device & CSIO_HW_CHIP_MASK)) | 2403 | if (csio_is_t5(pci_dev->device & CSIO_HW_CHIP_MASK)) |
2397 | fw_bin_file = FW_FNAME_T5; | 2404 | fw_bin_file = FW_FNAME_T5; |
2398 | else | 2405 | else |
@@ -2406,11 +2413,6 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset) | |||
2406 | fw_size = fw->size; | 2413 | fw_size = fw->size; |
2407 | } | 2414 | } |
2408 | 2415 | ||
2409 | /* allocate memory to read the header of the firmware on the | ||
2410 | * card | ||
2411 | */ | ||
2412 | card_fw = kmalloc(sizeof(*card_fw), GFP_KERNEL); | ||
2413 | |||
2414 | /* upgrade FW logic */ | 2416 | /* upgrade FW logic */ |
2415 | ret = csio_hw_prep_fw(hw, fw_info, fw_data, fw_size, card_fw, | 2417 | ret = csio_hw_prep_fw(hw, fw_info, fw_data, fw_size, card_fw, |
2416 | hw->fw_state, reset); | 2418 | hw->fw_state, reset); |