]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
RDMA/core: Check for verbs callbacks before using them
authorKamal Heib <kamalheib1@gmail.com>
Fri, 27 Jul 2018 18:23:05 +0000 (21:23 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 31 Jul 2018 02:31:09 +0000 (20:31 -0600)
Make sure the providers implement the verbs callbacks before calling
them, otherwise return -EOPNOTSUPP.

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/verbs.c

index d4c3bc042343baeac9df2e92d1fe93a855463591..b2af4eeb76693ceed202c8127f72adb7b02ecf8c 100644 (file)
@@ -2504,7 +2504,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);
 
index cde359d48d34c014d512ba15698b75085cf06604..5b76c7ebfa02d71bde091f2290aafb4607799ee0 100644 (file)
@@ -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)) {