All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: mpt3sas: fix error return code of mpt3sas_base_attach()
@ 2021-03-08  3:52 Jia-Ju Bai
  2021-03-25  3:53 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2021-03-08  3:52 UTC (permalink / raw)
  To: sathya.prakash, sreekanth.reddy, suganath-prabu.subramani, jejb,
	martin.petersen
  Cc: MPT-FusionLinux.pdl, linux-scsi, linux-kernel, 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.

Fixes: c696f7b83ede ("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>
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index ac066f86bb14..ac0eef975f17 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -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;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: mpt3sas: fix error return code of mpt3sas_base_attach()
  2021-03-08  3:52 [PATCH] scsi: mpt3sas: fix error return code of mpt3sas_base_attach() Jia-Ju Bai
@ 2021-03-25  3:53 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2021-03-25  3:53 UTC (permalink / raw)
  To: suganath-prabu.subramani, sathya.prakash, Jia-Ju Bai,
	sreekanth.reddy, jejb
  Cc: Martin K . Petersen, linux-scsi, linux-kernel, MPT-FusionLinux.pdl

On Sun, 7 Mar 2021 19:52:41 -0800, Jia-Ju Bai wrote:

> 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

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-25  3:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08  3:52 [PATCH] scsi: mpt3sas: fix error return code of mpt3sas_base_attach() Jia-Ju Bai
2021-03-25  3:53 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.