RDMA/mlx5: check reg_create() create for errors
Subsystems (3)
PATCH 1/1 RDMA/mlx5: check reg_create() create for errors
The reg_create() can fail. Check for errors before dereferencing it.
--- drivers/infiniband/hw/mlx5/mr.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/mlx5/mr.c +2 -0
@@ -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; }
Signature · 1 line
2.35.1
Quoted 26 lines
-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Monday, February 6, 2023 8:11 PM
To: Michael Guralnik <[email protected]>; Leon Romanovsky <[email protected]>
Cc: Jason Gunthorpe <[email protected]>; [email protected]; kernel- [email protected]
Subject: [PATCH] RDMA/mlx5: checkreg_create()create for errorsThe
reg_create()can fail. Check for errors before dereferencing it.Fixes dd1b913fb0d0 ("RDMA/mlx5: Cache all user cacheable mkeys on deregMR flow")
Signed-off-by Dan Carpenter <[email protected]>--- drivers/infiniband/hw/mlx5/mr.c | 2 ++ 1 file changed, 2 insertions(+)(quoted diff) +0
-0
b/drivers/infiniband/hw/mlx5/mr.cindexc396b942d0c8..2feab0818a76100644
drivers/infiniband/hw/mlx5/mr.c static struct mlx5_ib_mr · line 1170
Quoted 7 lines
drivers/infiniband/hw/mlx5/mr.c +2
-0@@ -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
Quoted 5 lines
drivers/infiniband/hw/mlx5/mr.c +0
-0mr->mmkey.rb_key = rb_key;drivers/infiniband/hw/mlx5/mr.c +0
-1return mr; } --2.35.1
Leon Romanovsky
AppliedQuoted 3 lines · Dan Carpenter
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,
Signature · 1 line
Leon Romanovsky <[email protected]>