[PATCH 2/9] RDMA/hfi2: Preserve unit 0 on allocation failure
Dennis Dalessandro <[email protected]> Mon, 03 Aug 2026 12:11:02 -0400
| Newsgroups | org.kernel.vger.linux-rdma |
|---|---|
| Message-ID | <178577346214.1793053.3536426297468803473.stgit@awdrv-04> |
When xa_alloc_irq() fails in hfi2_alloc_devdata(), the unit number (default 0) remains unchanged. Directly jumping to the common cleanup path incorrectly erases unit 0 from the xarray. Bail directly without calling hfi2_free_devdata() instead. Matches hfi1 fix 2e3809ad8911. Assisted-by: Claude:claude-sonnet-4-5 Signed-off-by: Dennis Dalessandro <[email protected]> --- drivers/infiniband/hw/hfi2/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/hfi2/init.c b/drivers/infiniband/hw/hfi2/init.c index 5b859ae7ae1e..2f2b116e9c57 100644 --- a/drivers/infiniband/hw/hfi2/init.c +++ b/drivers/infiniband/hw/hfi2/init.c @@ -2045,7 +2045,8 @@ static struct hfi2_devdata *hfi2_alloc_devdata(struct pci_dev *pdev, if (ret < 0) { dev_err(&pdev->dev, "Could not allocate unit ID: error %d\n", -ret); - goto bail; + rvt_dealloc_device(&dd->verbs_dev.rdi); + return ERR_PTR(ret); } dev_set_name(&dd->verbs_dev.rdi.ibdev.dev, "%s_%d", "hfi2", dd->unit); strscpy(dd->verbs_dev.rdi.ibdev.name,