Skip to contentSkip to conversation

scsi: mpt3sas: fix error return code of mpt3sas_base_attach()

PATCH Applied Jia-Ju Bai 2 participants 2 messages Mar 8, 2021 – Mar 25, 2021

Subsystems (2)
lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH 1/1 scsi: mpt3sas: fix error return code of mpt3sas_base_attach()

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.

Fixes c696f7b83ede ("scsi: mpt3sas: Implement device_remove_in_progress check in IOCTL path")
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +6 -2
index ac066f86bb14..ac0eef975f17 100644
@@ -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;
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Jia-Ju Bai

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.

Applied to 5.12/scsi-fixes, thanks!

[1/1] scsi: mpt3sas: fix error return code of mpt3sas_base_attach()

      https://git.kernel.org/mkp/scsi/c/3401ecf7fc1b
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering