diff options
author | Shirley Ma <xma@us.ibm.com> | 2005-12-15 21:25:33 +0000 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-11-09 11:35:58 -0800 |
commit | c4ecbe83483cdaf86f85b497dae6b4410d469c64 (patch) | |
tree | 94da926858e850e04dcaa43f3bf0d23f81fa7261 | |
parent | 572d4582861c43ebc7a91476e9d0ac4af784f292 (diff) | |
download | libibverbs-c4ecbe83483cdaf86f85b497dae6b4410d469c64.tar.gz |
Handle devices that don't support SRQ
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>
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/verbs.c | 6 |
2 files changed, 11 insertions, 1 deletions
@@ -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, diff --git a/src/verbs.c b/src/verbs.c index b9ababe..c80662f 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -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; |