diff mbox series

[1/1] scsi: mpt3sas: Fix error return value in _scsih_expander_add()

Message ID 20210514081300.6650-1-thunder.leizhen@huawei.com (mailing list archive)
State New, archived
Headers show
Series [1/1] scsi: mpt3sas: Fix error return value in _scsih_expander_add() | expand

Commit Message

Leizhen (ThunderTown) May 14, 2021, 8:13 a.m. UTC
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(-)

Comments

Martin K. Petersen June 19, 2021, 2:53 a.m. UTC | #1
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!
diff mbox series

Patch

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) {