linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-next] RDMA/core: Fix ib_qp_usecnt_dec() called when error
@ 2022-03-03  2:42 Yajun Deng
  2022-03-03 18:25 ` Leon Romanovsky
  2022-03-05  0:25 ` Jason Gunthorpe
  0 siblings, 2 replies; 3+ messages in thread
From: Yajun Deng @ 2022-03-03  2:42 UTC (permalink / raw)
  To: jgg, leonro; +Cc: linux-rdma, linux-kernel, Yajun Deng

ib_destroy_qp() would called by ib_create_qp_user() if error, the former
contains ib_qp_usecnt_dec(), but ib_qp_usecnt_inc() was not called before.

So move ib_qp_usecnt_inc() into create_qp().

Fixes: d2b10794fc13 ("RDMA/core: Create clean QP creations interface for uverbs")
Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 drivers/infiniband/core/uverbs_cmd.c          | 1 -
 drivers/infiniband/core/uverbs_std_types_qp.c | 1 -
 drivers/infiniband/core/verbs.c               | 3 +--
 3 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 6b6393176b3c..4437f834c0a7 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1437,7 +1437,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
 		ret = PTR_ERR(qp);
 		goto err_put;
 	}
-	ib_qp_usecnt_inc(qp);
 
 	obj->uevent.uobject.object = qp;
 	obj->uevent.event_file = READ_ONCE(attrs->ufile->default_async_file);
diff --git a/drivers/infiniband/core/uverbs_std_types_qp.c b/drivers/infiniband/core/uverbs_std_types_qp.c
index dd1075466f61..75353e09c6fe 100644
--- a/drivers/infiniband/core/uverbs_std_types_qp.c
+++ b/drivers/infiniband/core/uverbs_std_types_qp.c
@@ -254,7 +254,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)(
 		ret = PTR_ERR(qp);
 		goto err_put;
 	}
-	ib_qp_usecnt_inc(qp);
 
 	if (attr.qp_type == IB_QPT_XRC_TGT) {
 		obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object,
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index a9819c40a140..bc9a83f1ca2d 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1245,6 +1245,7 @@ static struct ib_qp *create_qp(struct ib_device *dev, struct ib_pd *pd,
 	if (ret)
 		goto err_security;
 
+	ib_qp_usecnt_inc(qp);
 	rdma_restrack_add(&qp->res);
 	return qp;
 
@@ -1345,8 +1346,6 @@ struct ib_qp *ib_create_qp_kernel(struct ib_pd *pd,
 	if (IS_ERR(qp))
 		return qp;
 
-	ib_qp_usecnt_inc(qp);
-
 	if (qp_init_attr->cap.max_rdma_ctxs) {
 		ret = rdma_rw_init_mrs(qp, qp_init_attr);
 		if (ret)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH for-next] RDMA/core: Fix ib_qp_usecnt_dec() called when error
  2022-03-03  2:42 [PATCH for-next] RDMA/core: Fix ib_qp_usecnt_dec() called when error Yajun Deng
@ 2022-03-03 18:25 ` Leon Romanovsky
  2022-03-05  0:25 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2022-03-03 18:25 UTC (permalink / raw)
  To: Yajun Deng; +Cc: jgg, linux-rdma, linux-kernel

On Thu, Mar 03, 2022 at 10:42:32AM +0800, Yajun Deng wrote:
> ib_destroy_qp() would called by ib_create_qp_user() if error, the former
> contains ib_qp_usecnt_dec(), but ib_qp_usecnt_inc() was not called before.
> 
> So move ib_qp_usecnt_inc() into create_qp().
> 
> Fixes: d2b10794fc13 ("RDMA/core: Create clean QP creations interface for uverbs")
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
>  drivers/infiniband/core/uverbs_cmd.c          | 1 -
>  drivers/infiniband/core/uverbs_std_types_qp.c | 1 -
>  drivers/infiniband/core/verbs.c               | 3 +--
>  3 files changed, 1 insertion(+), 4 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH for-next] RDMA/core: Fix ib_qp_usecnt_dec() called when error
  2022-03-03  2:42 [PATCH for-next] RDMA/core: Fix ib_qp_usecnt_dec() called when error Yajun Deng
  2022-03-03 18:25 ` Leon Romanovsky
@ 2022-03-05  0:25 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2022-03-05  0:25 UTC (permalink / raw)
  To: Yajun Deng; +Cc: leonro, linux-rdma, linux-kernel

On Thu, Mar 03, 2022 at 10:42:32AM +0800, Yajun Deng wrote:
> ib_destroy_qp() would called by ib_create_qp_user() if error, the former
> contains ib_qp_usecnt_dec(), but ib_qp_usecnt_inc() was not called before.
> 
> So move ib_qp_usecnt_inc() into create_qp().
> 
> Fixes: d2b10794fc13 ("RDMA/core: Create clean QP creations interface for uverbs")
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>  drivers/infiniband/core/uverbs_cmd.c          | 1 -
>  drivers/infiniband/core/uverbs_std_types_qp.c | 1 -
>  drivers/infiniband/core/verbs.c               | 3 +--
>  3 files changed, 1 insertion(+), 4 deletions(-)

Applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-05  0:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03  2:42 [PATCH for-next] RDMA/core: Fix ib_qp_usecnt_dec() called when error Yajun Deng
2022-03-03 18:25 ` Leon Romanovsky
2022-03-05  0:25 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).