Re: [PATCH] RDMA/hfi1: fix init_one() probe failure cleanup

From: Dawei Feng

Date: Mon Jul 06 2026 - 12:49:34 EST


On Sun, 5 Jul 2026 15:23:28 +0300, Leon Romanovsky wrote:
>Just move hfi1_validate_rcvhdrcnt() to be before hfi1_alloc_devdata()
>and remove error prints.

Hi, Leon,

I agree that this approach is suitable for the hfi1_validate_rcvhdrcnt()
failure path. However, it is not generally applicable to the other failure
paths. The later failures still occur after hfi1_alloc_devdata(), so they
still need proper cleanup handling to avoid leaking the allocated devdata.
Therefore, I think the current approach may be more appropriate for this
fix.

By the way, I also noticed that the error handling can be optimized by
returning ret directly from cleanup labels, avoiding chained gotos. Would
you like me to make this change in the next version? The change would look
like this:

+postinit_bail:
+ hfi1_free_rx(dd);
+ postinit_cleanup(dd);
+ return ret;
+
clean_bail:
hfi1_pcie_cleanup(pdev);
+ return ret;
+
+free_dd:
+ hfi1_free_devdata(dd);
+ return ret;
bail:
return ret;
}

Best regards,
Dawei