]> git.openfabrics.org - ~shefty/libibverbs.git/commitdiff
Handle devices that don't support SRQ
authorShirley Ma <xma@us.ibm.com>
Thu, 15 Dec 2005 21:25:33 +0000 (21:25 +0000)
committerRoland Dreier <rolandd@cisco.com>
Thu, 9 Nov 2006 19:35:58 +0000 (11:35 -0800)
create_srq is not a mandatory device function, therefore in
userspace/libibverbs/src/verbs.c ibv_create_srq should check
create_srq() first before calling it, otherwise the caller will cause
the segmentation fault on device which doesn't support SRQs.

Signed-off-by: Shirley Ma <xma@us.ibm.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
ChangeLog
src/verbs.c

index 4a069e12b3927a0718fd3dbdd85dabfe7042bb61..a117ce2073be53f76eb0e133e7dcd2ae6fa0d5ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-12-15  Roland Dreier  <rdreier@cisco.com>
+
+       * src/verbs.c (ibv_create_srq): Not all provider libraries will
+       support SRQs, so check if the create_srq method is defined before
+       calling it.  (Based on a patch from Shirley Ma <xma@us.ibm.com>)
+
 2005-11-11  Roland Dreier  <roland@cisco.com>
 
        * examples/asyncwatch.c, examples/rc_pingpong.c,
index b9ababe020d89f3c5883cd3f3b292241f4705b08..c80662f9c2aa1c6afc4287f11de68a87d58f555f 100644 (file)
@@ -246,8 +246,12 @@ void ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
 struct ibv_srq *ibv_create_srq(struct ibv_pd *pd,
                               struct ibv_srq_init_attr *srq_init_attr)
 {
-       struct ibv_srq *srq = pd->context->ops.create_srq(pd, srq_init_attr);
+       struct ibv_srq *srq;
 
+       if (!pd->context->ops.create_srq)
+               return NULL;
+
+       srq = pd->context->ops.create_srq(pd, srq_init_attr);
        if (srq) {
                srq->context          = pd->context;
                srq->srq_context      = srq_init_attr->srq_context;