Skip to contentSkip to conversation

scsi: megaraid_sas: fix error handle in megasas_probe_one

PATCH Applied weiping zhang 3 participants 3 messages Aug 7, 2017 – Aug 8, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: megaraid_sas: fix error handle in megasas_probe_one

megasas_mgmt_info.max_index has increased by 1 before megasas_io_attach, if megasas_io_attach return error, then goto fail_io_attach, megasas_mgmt_info.instance has a wrong index here. So first reduce max_index and then set that instance to NULL.

---
 drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_base.c +1 -1
index b5b9ba7..91eeec9 100644
@@ -6226,8 +6226,8 @@ static int megasas_probe_one(struct pci_dev *pdev,
 fail_start_aen:
 fail_io_attach:
 	megasas_mgmt_info.count--;
-	megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL;
 	megasas_mgmt_info.max_index--;
+	megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL;
 
 	instance->instancet->disable_intr(instance);
 	megasas_destroy_irqs(instance);
Signature · 1 line
2.9.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines

-----Original Message-----
From: weiping zhang [mailto:[email protected]]
Sent: Monday, August 07, 2017 10:57 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: [PATCH] scsi: megaraid_sas: fix error handle in

megasas_probe_one

Quoted 4 lines

megasas_mgmt_info.max_index has increased by 1 before megasas_io_attach, if megasas_io_attach return error, then goto fail_io_attach, megasas_mgmt_info.instance has a wrong index here. So

first

Quoted 22 lines

reduce max_index and then set that instance to NULL.

---
drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_base.c +0 -0
index b5b9ba7..91eeec9 100644
@@ -6226,8 +6226,8 @@ static int megasas_probe_one(struct pci_dev *pdev,

fail_start_aen:
fail_io_attach:

	megasas_mgmt_info.count--;
drivers/scsi/megaraid/megaraid_sas_base.c +0 -1
-	megasas_mgmt_info.instance[megasas_mgmt_info.max_index] =
NULL;
	megasas_mgmt_info.max_index--;
drivers/scsi/megaraid/megaraid_sas_base.c +1 -0
+	megasas_mgmt_info.instance[megasas_mgmt_info.max_index] =

NULL;

Quoted 2 lines
	instance->instancet->disable_intr(instance);
	megasas_destroy_irqs(instance);
Quoted 2 lines

--
2.9.4

#2 lore raw
In reply to weiping zhang

weiping,

Quoted 4 lines

megasas_mgmt_info.max_index has increased by 1 before megasas_io_attach, if megasas_io_attach return error, then goto fail_io_attach, megasas_mgmt_info.instance has a wrong index here. So first reduce max_index and then set that instance to NULL.

Applied to 4.13/scsi-fixes, thank you!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering