summaryrefslogtreecommitdiff
path: root/drivers/scsi/csiostor/csio_hw.c
diff options
context:
space:
mode:
authorVarun Prakash <varun@chelsio.com>2018-08-11 18:33:58 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-10 09:54:19 +0300
commit6054817c5e07702922603efc64c9568d60e3ee78 (patch)
tree5681d4b3fa43fdb3129851ec3491e0834e8b4569 /drivers/scsi/csiostor/csio_hw.c
parent4e380c50cf12f07d01262b81f5c61249503d2ce3 (diff)
downloadlinux-6054817c5e07702922603efc64c9568d60e3ee78.tar.xz
scsi: csiostor: add a check for NULL pointer after kmalloc()
[ Upstream commit 89809b028b6f54187b7d81a0c69b35d394c52e62 ] 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> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/scsi/csiostor/csio_hw.c')
-rw-r--r--drivers/scsi/csiostor/csio_hw.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c
index 5be0086142ca..ab30db8c36c6 100644
--- a/drivers/scsi/csiostor/csio_hw.c
+++ b/drivers/scsi/csiostor/csio_hw.c
@@ -2010,8 +2010,8 @@ bye:
}
/*
- * Returns -EINVAL if attempts to flash the firmware failed
- * else returns 0,
+ * Returns -EINVAL if attempts to flash the firmware failed,
+ * -ENOMEM if memory allocation failed else returns 0,
* if flashing was not attempted because the card had the
* latest firmware ECANCELED is returned
*/
@@ -2039,6 +2039,13 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset)
return -EINVAL;
}
+ /* allocate memory to read the header of the firmware on the
+ * card
+ */
+ card_fw = kmalloc(sizeof(*card_fw), GFP_KERNEL);
+ if (!card_fw)
+ return -ENOMEM;
+
if (csio_is_t5(pci_dev->device & CSIO_HW_CHIP_MASK))
fw_bin_file = FW_FNAME_T5;
else
@@ -2052,11 +2059,6 @@ csio_hw_flash_fw(struct csio_hw *hw, int *reset)
fw_size = fw->size;
}
- /* allocate memory to read the header of the firmware on the
- * card
- */
- card_fw = kmalloc(sizeof(*card_fw), GFP_KERNEL);
-
/* upgrade FW logic */
ret = csio_hw_prep_fw(hw, fw_info, fw_data, fw_size, card_fw,
hw->fw_state, reset);