Skip to content

Commit

Permalink
scsi: mpt3sas: Fix error return code of mpt3sas_base_attach()
Browse files Browse the repository at this point in the history
When kzalloc() returns NULL, no error return code of mpt3sas_base_attach()
is assigned. To fix this bug, r is assigned with -ENOMEM in this case.

Link: https://lore.kernel.org/r/20210308035241.3288-1-baijiaju1990@gmail.com
Fixes: c696f7b ("scsi: mpt3sas: Implement device_remove_in_progress check in IOCTL path")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Jia-Ju Bai authored and Martin K. Petersen committed Mar 25, 2021
1 parent f699538 commit 3401ecf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/scsi/mpt3sas/mpt3sas_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -7806,14 +7806,18 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
ioc->pend_os_device_add_sz++;
ioc->pend_os_device_add = kzalloc(ioc->pend_os_device_add_sz,
GFP_KERNEL);
if (!ioc->pend_os_device_add)
if (!ioc->pend_os_device_add) {
r = -ENOMEM;
goto out_free_resources;
}

ioc->device_remove_in_progress_sz = ioc->pend_os_device_add_sz;
ioc->device_remove_in_progress =
kzalloc(ioc->device_remove_in_progress_sz, GFP_KERNEL);
if (!ioc->device_remove_in_progress)
if (!ioc->device_remove_in_progress) {
r = -ENOMEM;
goto out_free_resources;
}

ioc->fwfault_debug = mpt3sas_fwfault_debug;

Expand Down

0 comments on commit 3401ecf

Please sign in to comment.