Skip to contentSkip to conversation

IB/hfi1: fix error paths in hfi1_mod_init()

PATCH Applied Wanhui Fu 3 participants 3 messages Nov 23 – Nov 25

Subsystems (2)
lore
Share & tools
lore

Wanhui Fu

author
#0 lore raw

PATCH v2 1/1 IB/hfi1: fix error paths in hfi1_mod_init()

The error path in hfi1_mod_init() is not completed. Fix this by add some goto label.

Fixes d63730192f59 ("IB/hfi1: Reserve and collapse CPU cores for contexts")
Fixes 48a615dc00ae ("IB/hfi1: Integrate OPFN into RC transactions")

---
Changes in v2:
- Add Fixes tags as suggested by Sashiko.

---
 drivers/infiniband/hw/hfi1/init.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/infiniband/hw/hfi1/init.c +8 -4
index f94d896e7212..c66d4dea5fc6 100644
@@ -1388,7 +1388,7 @@ static int __init hfi1_mod_init(void)
 
 	ret = node_affinity_init();
 	if (ret)
-		goto bail;
+		goto bail_dev;
 
 	/* validate max MTU before any devices start */
 	if (!valid_opa_max_mtu(hfi1_max_mtu)) {
@@ -1438,7 +1438,7 @@ static int __init hfi1_mod_init(void)
 	ret = opfn_init();
 	if (ret < 0) {
 		pr_err("Failed to allocate opfn_wq");
-		goto bail_dev;
+		goto bail_affinity;
 	}
 
 	/*
@@ -1449,12 +1449,16 @@ static int __init hfi1_mod_init(void)
 	ret = pci_register_driver(&hfi1_pci_driver);
 	if (ret < 0) {
 		pr_err("Unable to register driver: error %d\n", -ret);
-		goto bail_dev;
+		goto bail_opfn;
 	}
 	goto bail; /* all OK */
 
-bail_dev:
+bail_opfn:
 	hfi1_dbg_exit();
+	opfn_exit();
+bail_affinity:
+	node_affinity_destroy_all();
+bail_dev:
 	dev_cleanup();
 bail:
 	return ret;
Signature · 1 line
2.25.1
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines

The error path in hfi1_mod_init() is not completed. Fix this by add some goto label.

Fixes d63730192f59 ("IB/hfi1: Reserve and collapse CPU cores for contexts")
Fixes 48a615dc00ae ("IB/hfi1: Integrate OPFN into RC transactions")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1