All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] scsi: mpt3sas: Fix error return value in _scsih_expander_add()
@ 2021-05-14  8:13 Zhen Lei
  2021-06-19  2:53 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Zhen Lei @ 2021-05-14  8:13 UTC (permalink / raw)
  To: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani,
	James E . J . Bottomley, Martin K . Petersen,
	Nagalakshmi Nandigama, James Bottomley, MPT-FusionLinux,
	linux-scsi
  Cc: Zhen Lei

When an expander does not contain any 'phys', an appropriate error code -1
should be returned, as done elsewhere in this function. However, we
currently do not explicitly assign this error code to 'rc'. As a result,
0 was incorrectly returned.

Fixes: f92363d12359 ("[SCSI] mpt3sas: add new driver supporting 12GB SAS")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index d00aca3c77cec22..a5f70f0e0287147 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -6884,8 +6884,10 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle)
 		 handle, parent_handle,
 		 (u64)sas_expander->sas_address, sas_expander->num_phys);
 
-	if (!sas_expander->num_phys)
+	if (!sas_expander->num_phys) {
+		rc = -1;
 		goto out_fail;
+	}
 	sas_expander->phy = kcalloc(sas_expander->num_phys,
 	    sizeof(struct _sas_phy), GFP_KERNEL);
 	if (!sas_expander->phy) {
-- 
2.26.0.106.g9fadedd



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

* Re: [PATCH 1/1] scsi: mpt3sas: Fix error return value in _scsih_expander_add()
  2021-05-14  8:13 [PATCH 1/1] scsi: mpt3sas: Fix error return value in _scsih_expander_add() Zhen Lei
@ 2021-06-19  2:53 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2021-06-19  2:53 UTC (permalink / raw)
  To: Zhen Lei
  Cc: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani,
	James E . J . Bottomley, Martin K . Petersen,
	Nagalakshmi Nandigama, James Bottomley, MPT-FusionLinux,
	linux-scsi


Zhen,

> When an expander does not contain any 'phys', an appropriate error
> code -1 should be returned, as done elsewhere in this
> function. However, we currently do not explicitly assign this error
> code to 'rc'. As a result, 0 was incorrectly returned.

Applied to 5.14/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2021-06-19  2:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14  8:13 [PATCH 1/1] scsi: mpt3sas: Fix error return value in _scsih_expander_add() Zhen Lei
2021-06-19  2: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.