diff mbox series

[rdma-rc] RDMA/cma: add cm_id restrack resource based on kernel or user cm_id type

Message ID 20190107190608.6ACF9227A6@smtp.opengridcomputing.com (mailing list archive)
State Mainlined
Commit 917cb8a72a94d198073ad1e087685f801292042d
Delegated to: Jason Gunthorpe
Headers show
Series [rdma-rc] RDMA/cma: add cm_id restrack resource based on kernel or user cm_id type | expand

Commit Message

Steve Wise Jan. 7, 2019, 7:01 p.m. UTC
A recent regression causes a null ptr crash when dumping cm_id resources.
The cma is incorrectly adding all cm_id restrack resources as kernel mode.

Fixes: af8d70375d56 ("RDMA/restrack: Resource-tracker should not use uobject pointers")
Signed-off-by: Steve Wise <swise@opengridcomputing.com>
---
 drivers/infiniband/core/cma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Leon Romanovsky Jan. 8, 2019, 6:21 a.m. UTC | #1
On Mon, Jan 07, 2019 at 11:01:13AM -0800, Steve Wise wrote:
> A recent regression causes a null ptr crash when dumping cm_id resources.
> The cma is incorrectly adding all cm_id restrack resources as kernel mode.
>
> Fixes: af8d70375d56 ("RDMA/restrack: Resource-tracker should not use uobject pointers")
> Signed-off-by: Steve Wise <swise@opengridcomputing.com>
> ---
>  drivers/infiniband/core/cma.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 63a7cc00bae0..84f077b2b90a 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -494,7 +494,10 @@ static void _cma_attach_to_dev(struct rdma_id_private *id_priv,
>  	id_priv->id.route.addr.dev_addr.transport =
>  		rdma_node_get_transport(cma_dev->device->node_type);
>  	list_add_tail(&id_priv->list, &cma_dev->id_list);
> -	rdma_restrack_kadd(&id_priv->res);
> +	if (id_priv->res.kern_name)
> +		rdma_restrack_kadd(&id_priv->res);
> +	else
> +		rdma_restrack_uadd(&id_priv->res);
>  }
>

Jason, Doug

Please be aware that this bugfix is needed in for-next too.

Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

Thanks
Jason Gunthorpe Jan. 9, 2019, 12:13 a.m. UTC | #2
On Mon, Jan 07, 2019 at 11:01:13AM -0800, Steve Wise wrote:
> A recent regression causes a null ptr crash when dumping cm_id resources.
> The cma is incorrectly adding all cm_id restrack resources as kernel mode.
> 
> Fixes: af8d70375d56 ("RDMA/restrack: Resource-tracker should not use uobject pointers")
> Signed-off-by: Steve Wise <swise@opengridcomputing.com>
> ---
>  drivers/infiniband/core/cma.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Applied to for-rc

Thanks,
Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 63a7cc00bae0..84f077b2b90a 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -494,7 +494,10 @@  static void _cma_attach_to_dev(struct rdma_id_private *id_priv,
 	id_priv->id.route.addr.dev_addr.transport =
 		rdma_node_get_transport(cma_dev->device->node_type);
 	list_add_tail(&id_priv->list, &cma_dev->id_list);
-	rdma_restrack_kadd(&id_priv->res);
+	if (id_priv->res.kern_name)
+		rdma_restrack_kadd(&id_priv->res);
+	else
+		rdma_restrack_uadd(&id_priv->res);
 }
 
 static void cma_attach_to_dev(struct rdma_id_private *id_priv,