* Re: [PATCH] drivers: fix the exception was not returned
2025-09-16 13:49 ` Leon Romanovsky
@ 2025-09-17 2:15 ` YanLong Dai
2025-09-17 11:35 ` [PATCH] drivers: fix the potential memory leak in bnxt_re_destroy_gsi_sqp() YanLong Dai
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: YanLong Dai @ 2025-09-17 2:15 UTC (permalink / raw)
To: leon
Cc: daiyanlong, dyl_wlc, jgg, kalesh-anakkur.purayil, linux-kernel,
linux-rdma, selvin.xavier
On Tue, Sep 16, 2025 at 04:49:15PM +0300, Leon Romanovsky wrote:
> On Tue, Sep 16, 2025 at 05:11:54PM +0800, YanLong Dai wrote:
> > From: daiyanlong <daiyanlong@kylinos.cn>
> >
> > The return value rc of bnxt_qplib_destroy_qp is abnormal and no return
>
> And what is wrong with that? This is expected behavior - do not fail if
> destroy fails.
Thank you for the feedback! I understand your perspective that destroy operations should ideally complete cleanup whenever possible.
However, while reviewing the related code, I noticed a consistency detail:
In the bnxt_re_destroy_gsi_sqp() function within the same file (drivers/infiniband/hw/bnxt_re/ib_verbs.c), the error handling for bnxt_qplib_destroy_qp() is different:
static void bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
{
...
rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp);
if (rc) {
ibdev_err(...); // <- logs a warning here
goto fail; // <- returns immediately without further cleanup
}
bnxt_qplib_free_qp_res(&rdev->qplib_res, &qp->qplib_qp); // <- cleans up resources
fail:
return rc;
}
Whereas in the function addressed by the current patch:
static int bnxt_re_destroy_qp(...)
{
...
rc = bnxt_qplib_destroy_qp(&qp->qplib_qp);
if (rc)
ibdev_err(&rdev->ibdev, "Failed to destroy HW QP");
// no check of rc, proceeds directly to cleanup
bnxt_qplib_free_qp_res(&qp->qplib_qp);
}
My consideration is:
If bnxt_qplib_free_qp_res() is called after bnxt_qplib_destroy_qp() fails, could this potentially lead to
This might be a minor robustness concern in the code. Of course, you as the maintainer have the best understanding of the code context. If this is an intentional design decision, please feel free to disregard my suggestion.
Thank you for your time!
YanLong
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH] drivers: fix the potential memory leak in bnxt_re_destroy_gsi_sqp()
2025-09-16 13:49 ` Leon Romanovsky
2025-09-17 2:15 ` YanLong Dai
@ 2025-09-17 11:35 ` YanLong Dai
2025-09-18 10:02 ` Leon Romanovsky
2025-09-17 12:13 ` [PATCH v2] " YanLong Dai
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: YanLong Dai @ 2025-09-17 11:35 UTC (permalink / raw)
To: kalesh-anakkur.purayil
Cc: jgg, leon, linux-kernel, linux-rdma, selvin.xavier, daiyanlong,
dyl_wlc
From: daiyanlong <daiyanlong@kylinos.cn>
As suggested by Kalesh Anakkur Purayil, fix the potential memory leak in bnxt_re_destroy_gsi_sqp() by continuing the teardown even if bnxt_qplib_destroy_qp() fails, we should not fail the resource destroy operations
Signed-off-by: daiyanlong <daiyanlong@kylinos.cn>
---
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 260dc67b8b87..adee44aa0583 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -931,10 +931,9 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
ibdev_dbg(&rdev->ibdev, "Destroy the shadow QP\n");
rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &gsi_sqp->qplib_qp);
- if (rc) {
+ if (rc)
ibdev_err(&rdev->ibdev, "Destroy Shadow QP failed");
- goto fail;
- }
+
bnxt_qplib_free_qp_res(&rdev->qplib_res, &gsi_sqp->qplib_qp);
/* remove from active qp list */
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] drivers: fix the potential memory leak in bnxt_re_destroy_gsi_sqp()
2025-09-17 11:35 ` [PATCH] drivers: fix the potential memory leak in bnxt_re_destroy_gsi_sqp() YanLong Dai
@ 2025-09-18 10:02 ` Leon Romanovsky
0 siblings, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2025-09-18 10:02 UTC (permalink / raw)
To: YanLong Dai
Cc: kalesh-anakkur.purayil, jgg, linux-kernel, linux-rdma,
selvin.xavier, daiyanlong
On Wed, Sep 17, 2025 at 07:35:39PM +0800, YanLong Dai wrote:
> From: daiyanlong <daiyanlong@kylinos.cn>
>
> As suggested by Kalesh Anakkur Purayil, fix the potential memory leak in bnxt_re_destroy_gsi_sqp() by continuing the teardown even if bnxt_qplib_destroy_qp() fails, we should not fail the resource destroy operations
>
> Signed-off-by: daiyanlong <daiyanlong@kylinos.cn>
> ---
> drivers/infiniband/hw/bnxt_re/ib_verbs.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
Please resend this patch as standalone and not as Reply-to to other conversion.
While you are doing that, make sure that your patch pass checkpatch.pl, break lines
in commit message, use real name in Signed-off-by and From fields, and
remove "rc" variable too, which is not used.
Thanks
>
> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> index 260dc67b8b87..adee44aa0583 100644
> --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> @@ -931,10 +931,9 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
>
> ibdev_dbg(&rdev->ibdev, "Destroy the shadow QP\n");
> rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &gsi_sqp->qplib_qp);
> - if (rc) {
> + if (rc)
> ibdev_err(&rdev->ibdev, "Destroy Shadow QP failed");
> - goto fail;
> - }
> +
> bnxt_qplib_free_qp_res(&rdev->qplib_res, &gsi_sqp->qplib_qp);
>
> /* remove from active qp list */
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] drivers: fix the potential memory leak in bnxt_re_destroy_gsi_sqp()
2025-09-16 13:49 ` Leon Romanovsky
2025-09-17 2:15 ` YanLong Dai
2025-09-17 11:35 ` [PATCH] drivers: fix the potential memory leak in bnxt_re_destroy_gsi_sqp() YanLong Dai
@ 2025-09-17 12:13 ` YanLong Dai
2025-09-17 12:39 ` [PATCH v3] " YanLong Dai
2025-09-17 12:40 ` YanLong Dai
4 siblings, 0 replies; 8+ messages in thread
From: YanLong Dai @ 2025-09-17 12:13 UTC (permalink / raw)
To: kalesh-anakkur.purayil
Cc: jgg, leon, linux-kernel, linux-rdma, selvin.xavier, daiyanlong,
dyl_wlc
From: daiyanlong <daiyanlong@kylinos.cn>
As suggested by Kalesh Anakkur Purayil, fix the potential memory leak in bnxt_re_destroy_gsi_sqp() by continuing the teardown even if bnxt_qplib_destroy_qp() fails, we should not fail the resource destroy operations
Eliminates the 'fail:' label and associated return statement
Signed-off-by: daiyanlong <daiyanlong@kylinos.cn>
---
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 260dc67b8b87..15d3f5d5c0ee 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -931,10 +931,9 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
ibdev_dbg(&rdev->ibdev, "Destroy the shadow QP\n");
rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &gsi_sqp->qplib_qp);
- if (rc) {
+ if (rc)
ibdev_err(&rdev->ibdev, "Destroy Shadow QP failed");
- goto fail;
- }
+
bnxt_qplib_free_qp_res(&rdev->qplib_res, &gsi_sqp->qplib_qp);
/* remove from active qp list */
@@ -951,8 +950,6 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
rdev->gsi_ctx.sqp_tbl = NULL;
return 0;
-fail:
- return rc;
}
/* Queue Pairs */
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v3] drivers: fix the potential memory leak in bnxt_re_destroy_gsi_sqp()
2025-09-16 13:49 ` Leon Romanovsky
` (2 preceding siblings ...)
2025-09-17 12:13 ` [PATCH v2] " YanLong Dai
@ 2025-09-17 12:39 ` YanLong Dai
2025-09-17 12:40 ` YanLong Dai
4 siblings, 0 replies; 8+ messages in thread
From: YanLong Dai @ 2025-09-17 12:39 UTC (permalink / raw)
To: kalesh-anakkur.purayil
Cc: jgg, leon, linux-kernel, linux-rdma, selvin.xavier, daiyanlong,
dyl_wlc
From: daiyanlong <daiyanlong@kylinos.cn>
As suggested by Kalesh Anakkur Purayil, fix the potential memory leak in
bnxt_re_destroy_gsi_sqp() by continuing the teardown even if
bnxt_qplib_destroy_qp() fails, weshould not fail the resource
destroy operations
Eliminates the 'fail:' label and associated return statement
Modify commit information exceeding 75 bytes
Signed-off-by: daiyanlong <daiyanlong@kylinos.cn>
---
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 260dc67b8b87..15d3f5d5c0ee 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -931,10 +931,9 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
ibdev_dbg(&rdev->ibdev, "Destroy the shadow QP\n");
rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &gsi_sqp->qplib_qp);
- if (rc) {
+ if (rc)
ibdev_err(&rdev->ibdev, "Destroy Shadow QP failed");
- goto fail;
- }
+
bnxt_qplib_free_qp_res(&rdev->qplib_res, &gsi_sqp->qplib_qp);
/* remove from active qp list */
@@ -951,8 +950,6 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
rdev->gsi_ctx.sqp_tbl = NULL;
return 0;
-fail:
- return rc;
}
/* Queue Pairs */
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v3] drivers: fix the potential memory leak in bnxt_re_destroy_gsi_sqp()
2025-09-16 13:49 ` Leon Romanovsky
` (3 preceding siblings ...)
2025-09-17 12:39 ` [PATCH v3] " YanLong Dai
@ 2025-09-17 12:40 ` YanLong Dai
4 siblings, 0 replies; 8+ messages in thread
From: YanLong Dai @ 2025-09-17 12:40 UTC (permalink / raw)
To: kalesh-anakkur.purayil
Cc: jgg, leon, linux-kernel, linux-rdma, selvin.xavier, daiyanlong,
dyl_wlc
From: daiyanlong <daiyanlong@kylinos.cn>
As suggested by Kalesh Anakkur Purayil, fix the potential memory leak in
bnxt_re_destroy_gsi_sqp() by continuing the teardown even if
bnxt_qplib_destroy_qp() fails, weshould not fail the resource
destroy operations
Eliminates the 'fail:' label and associated return statement
Modify commit information exceeding 75 bytes
Signed-off-by: daiyanlong <daiyanlong@kylinos.cn>
---
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 260dc67b8b87..15d3f5d5c0ee 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -931,10 +931,9 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
ibdev_dbg(&rdev->ibdev, "Destroy the shadow QP\n");
rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &gsi_sqp->qplib_qp);
- if (rc) {
+ if (rc)
ibdev_err(&rdev->ibdev, "Destroy Shadow QP failed");
- goto fail;
- }
+
bnxt_qplib_free_qp_res(&rdev->qplib_res, &gsi_sqp->qplib_qp);
/* remove from active qp list */
@@ -951,8 +950,6 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
rdev->gsi_ctx.sqp_tbl = NULL;
return 0;
-fail:
- return rc;
}
/* Queue Pairs */
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread