[PATCH] RDMA/mlx5: return the EFAULT per ibv_advise_mr(3)

Li Zhijian
2021-08-01T09:23:05Z

ibv_advise_mr(3) says:
EFAULT In one of the following: o When the range requested is out of the MR bounds,
or when parts of it are not part of the process address space. o One of the
lkeys provided in the scatter gather list is invalid or with wrong write access

Actually get_prefetchable_mr() will return NULL if it see above conditions

Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
drivers/infiniband/hw/mlx5/odp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c
index d0d98e584ebc..8d2a626c87cf 100644
--- a/drivers/infiniband/hw/mlx5/odp.c
+++ b/drivers/infiniband/hw/mlx5/odp.c
@@ -1791,7 +1791,7 @@ static int mlx5_ib_prefetch_sg_list(struct ib_pd *pd,

mr = get_prefetchable_mr(pd, advice, sg_list[i].lkey);
if (!mr)
- return -ENOENT;
+ return -EFAULT;
ret = pagefault_mr(mr, sg_list[i].addr, sg_list[i].length,
&bytes_mapped, pf_flags);
if (ret < 0) {
--
2.30.2