Skip to content

Commit 312320b

Browse files
Justin Teemartinkpetersen
authored andcommitted
scsi: lpfc: Check kzalloc() in lpfc_sli4_cgn_params_read()
If kzalloc() fails in lpfc_sli4_cgn_params_read(), then we rely on lpfc_read_object()'s routine to NULL check pdata. Currently, an early return error is thrown from lpfc_read_object() to protect us from NULL ptr dereference, but the errno code is -ENODEV. Change the errno code to a more appropriate -ENOMEM. Reported-by: Kang Chen <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Justin Tee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent c9507ea commit 312320b

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7291,6 +7291,8 @@ lpfc_sli4_cgn_params_read(struct lpfc_hba *phba)
72917291
/* Find out if the FW has a new set of congestion parameters. */
72927292
len = sizeof(struct lpfc_cgn_param);
72937293
pdata = kzalloc(len, GFP_KERNEL);
7294+
if (!pdata)
7295+
return -ENOMEM;
72947296
ret = lpfc_read_object(phba, (char *)LPFC_PORT_CFG_NAME,
72957297
pdata, len);
72967298

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22109,10 +22109,6 @@ lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap,
2210922109
struct lpfc_dmabuf *pcmd;
2211022110
u32 rd_object_name[LPFC_MBX_OBJECT_NAME_LEN_DW] = {0};
2211122111

22112-
/* sanity check on queue memory */
22113-
if (!datap)
22114-
return -ENODEV;
22115-
2211622112
mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
2211722113
if (!mbox)
2211822114
return -ENOMEM;

0 commit comments

Comments
 (0)