Message ID | Y+ERYy4wN0LsKsm+@kili (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | RDMA/mlx5: check reg_create() create for errors | expand |
> -----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
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,
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; }
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(+)