[openib-general] patch: ibv_query_qp() causes segmentation fault if init_attr is NULL

Hoang-Nam Nguyen HNGUYEN at de.ibm.com
Thu May 11 11:08:56 PDT 2006


Hi Roland!
Just realized in one of our testcases that ibv_query_qp() causes a
segmentation fault if the parameter init_attr is NULL. Not sure if I'm
wrong, but init_attr appears to be optional, isn't it?
Anyway here is my patch for review:

Index: src/userspace/libibverbs/src/cmd.c
===================================================================
--- src/userspace/libibverbs/src/cmd.c    (revision 7064)
+++ src/userspace/libibverbs/src/cmd.c    (working copy)
@@ -673,17 +673,19 @@
      attr->alt_ah_attr.is_global         = resp.alt_dest.is_global;
      attr->alt_ah_attr.port_num          = resp.alt_dest.port_num;

-     init_attr->qp_context               = qp->qp_context;
-     init_attr->send_cq                  = qp->send_cq;
-     init_attr->recv_cq                  = qp->recv_cq;
-     init_attr->srq                      = qp->srq;
-     init_attr->qp_type                  = qp->qp_type;
-     init_attr->cap.max_send_wr          = resp.max_send_wr;
-     init_attr->cap.max_recv_wr          = resp.max_recv_wr;
-     init_attr->cap.max_send_sge         = resp.max_send_sge;
-     init_attr->cap.max_recv_sge         = resp.max_recv_sge;
-     init_attr->cap.max_inline_data      = resp.max_inline_data;
-     init_attr->sq_sig_all               = resp.sq_sig_all;
+     if (init_attr) {
+           init_attr->qp_context               = qp->qp_context;
+           init_attr->send_cq                  = qp->send_cq;
+           init_attr->recv_cq                  = qp->recv_cq;
+           init_attr->srq                      = qp->srq;
+           init_attr->qp_type                  = qp->qp_type;
+           init_attr->cap.max_send_wr          = resp.max_send_wr;
+           init_attr->cap.max_recv_wr          = resp.max_recv_wr;
+           init_attr->cap.max_send_sge         = resp.max_send_sge;
+           init_attr->cap.max_recv_sge         = resp.max_recv_sge;
+           init_attr->cap.max_inline_data      = resp.max_inline_data;
+           init_attr->sq_sig_all               = resp.sq_sig_all;
+     }

      return 0;
 }

Thanks!

Mit freundlichen Gruessen/Kind Regards
Hoang-Nam Nguyen

(See attached file: cmd.c_trunk_7064.diff)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmd.c_trunk_7064.diff
Type: application/octet-stream
Size: 1657 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20060511/f09feb32/attachment.obj>


More information about the general mailing list