mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
scsi: csiostor: add a check for NULL pointer after kmalloc()
[ Upstream commit 89809b028b ]
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c31c8008c7
commit
74a3017016
@@ -2275,8 +2275,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
|
||||
*/
|
||||
@@ -2304,6 +2304,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
|
||||
@@ -2317,11 +2324,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);
|
||||
|
||||
Reference in New Issue
Block a user