Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH] RDMA/mlx5: check reg_create() create for errors
@ 2023-02-06 14:40 Dan Carpenter
  2023-02-07  5:19 ` Devesh Sharma
  2023-02-07 10:28 ` Leon Romanovsky
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-02-06 14:40 UTC (permalink / raw)
  To: Michael Guralnik, Leon Romanovsky
  Cc: Jason Gunthorpe, linux-rdma, kernel-janitors

The reg_create() can fail.  Check for errors before dereferencing it.

Fixes: dd1b913fb0d0 ("RDMA/mlx5: Cache all user cacheable mkeys on dereg MR flow")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
 drivers/infiniband/hw/mlx5/mr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index c396b942d0c8..2feab0818a76 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -1164,6 +1164,8 @@ static struct mlx5_ib_mr *alloc_cacheable_mr(struct ib_pd *pd,
 		mutex_lock(&dev->slow_path_mutex);
 		mr = reg_create(pd, umem, iova, access_flags, page_size, false);
 		mutex_unlock(&dev->slow_path_mutex);
+		if (IS_ERR(mr))
+			return mr;
 		mr->mmkey.rb_key = rb_key;
 		return mr;
 	}
-- 
2.35.1


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

* RE: [PATCH] RDMA/mlx5: check reg_create() create for errors
  2023-02-06 14:40 [PATCH] RDMA/mlx5: check reg_create() create for errors Dan Carpenter
@ 2023-02-07  5:19 ` Devesh Sharma
  2023-02-07 10:28 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Devesh Sharma @ 2023-02-07  5:19 UTC (permalink / raw)
  To: Dan Carpenter, Michael Guralnik, Leon Romanovsky
  Cc: Jason Gunthorpe, linux-rdma@vger.kernel.org,
	kernel-janitors@vger.kernel.org



> -----Original Message-----
> From: Dan Carpenter <error27@gmail.com>
> Sent: Monday, February 6, 2023 8:11 PM
> To: Michael Guralnik <michaelgur@nvidia.com>; Leon Romanovsky
> <leon@kernel.org>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>; linux-rdma@vger.kernel.org; kernel-
> janitors@vger.kernel.org
> Subject: [PATCH] RDMA/mlx5: check reg_create() create for errors
> 
> The reg_create() can fail.  Check for errors before dereferencing it.
> 
> Fixes: dd1b913fb0d0 ("RDMA/mlx5: Cache all user cacheable mkeys on dereg
> MR flow")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
>  drivers/infiniband/hw/mlx5/mr.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/infiniband/hw/mlx5/mr.c
> b/drivers/infiniband/hw/mlx5/mr.c index c396b942d0c8..2feab0818a76
> 100644
> --- a/drivers/infiniband/hw/mlx5/mr.c
> +++ b/drivers/infiniband/hw/mlx5/mr.c
> @@ -1164,6 +1164,8 @@ static struct mlx5_ib_mr
> *alloc_cacheable_mr(struct ib_pd *pd,
>  		mutex_lock(&dev->slow_path_mutex);
>  		mr = reg_create(pd, umem, iova, access_flags, page_size,
> false);
>  		mutex_unlock(&dev->slow_path_mutex);
> +		if (IS_ERR(mr))
> +			return mr;


Looks good
Reviewed-by: Devesh Sharma <devesh.s.sharma@oracle.com>

>  		mr->mmkey.rb_key = rb_key;
>  		return mr;
>  	}
> --
> 2.35.1


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

* Re: [PATCH] RDMA/mlx5: check reg_create() create for errors
  2023-02-06 14:40 [PATCH] RDMA/mlx5: check reg_create() create for errors Dan Carpenter
  2023-02-07  5:19 ` Devesh Sharma
@ 2023-02-07 10:28 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2023-02-07 10:28 UTC (permalink / raw)
  To: Michael Guralnik, Dan Carpenter
  Cc: Jason Gunthorpe, linux-rdma, kernel-janitors


On Mon, 06 Feb 2023 17:40:35 +0300, Dan Carpenter wrote:
> The reg_create() can fail.  Check for errors before dereferencing it.
> 
> 

Applied, thanks!

[1/1] RDMA/mlx5: check reg_create() create for errors
      https://git.kernel.org/rdma/rdma/c/8e6e49ccf1a0f2

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>

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

end of thread, other threads:[~2023-02-07 10:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-06 14:40 [PATCH] RDMA/mlx5: check reg_create() create for errors Dan Carpenter
2023-02-07  5:19 ` Devesh Sharma
2023-02-07 10:28 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox