diff mbox

[rdma-next,v2,2/3] RDMA/core: Check for verbs callbacks before using them

Message ID 20180714232811.9164-3-kamalheib1@gmail.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Kamal Heib July 14, 2018, 11:28 p.m. UTC
Make sure the providers implement the verbs callbacks before calling
them, otherwise return -EOPNOTSUPP.

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
---
 drivers/infiniband/core/uverbs_cmd.c | 3 ++-
 drivers/infiniband/core/verbs.c      | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Leon Romanovsky July 24, 2018, 6:16 a.m. UTC | #1
On Sun, Jul 15, 2018 at 02:28:10AM +0300, Kamal Heib wrote:
> Make sure the providers implement the verbs callbacks before calling
> them, otherwise return -EOPNOTSUPP.
>
> Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
> ---
>  drivers/infiniband/core/uverbs_cmd.c | 3 ++-
>  drivers/infiniband/core/verbs.c      | 3 +++
>  2 files changed, 5 insertions(+), 1 deletion(-)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
diff mbox

Patch

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index bd6eefaecbd6..6ab00f322b62 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -2507,7 +2507,8 @@  ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
 		goto out;
 
 	resp.bad_wr = 0;
-	ret = srq->device->post_srq_recv(srq, wr, &bad_wr);
+	ret = srq->device->post_srq_recv ?
+		srq->device->post_srq_recv(srq, wr, &bad_wr) : -EOPNOTSUPP;
 
 	uobj_put_obj_read(srq);
 
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index b6ceb6fd6a67..9daae59572ac 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -479,6 +479,9 @@  static struct ib_ah *_rdma_create_ah(struct ib_pd *pd,
 {
 	struct ib_ah *ah;
 
+	if (!pd->device->create_ah)
+		return ERR_PTR(-EOPNOTSUPP);
+
 	ah = pd->device->create_ah(pd, ah_attr, udata);
 
 	if (!IS_ERR(ah)) {