From: Roland Dreier Date: Tue, 20 Nov 2007 21:12:15 +0000 (-0800) Subject: Always return valid bad_wr on error from ibv_post_{send,recv,srq_recv} X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=c6b9bda129455d6d5da79eab8d3d13844ad8df1b;p=~shefty%2Flibibverbs.git Always return valid bad_wr on error from ibv_post_{send,recv,srq_recv} There are error cases in the kernel's uverbs work request posting functions where the return value is negative (i.e., an error) and yet a non-zero resp.bad_wr is not written back to userspace. In this case, ibv_cmd_post_send() should still set the bad_wr pointer. Bug pointed out in ibv_post_send() by Ralph Campbell , and noticed elsewhere by Dotan Barak . Signed-off-by: Roland Dreier --- diff --git a/src/cmd.c b/src/cmd.c index 6d4331f..31b592e 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -884,7 +884,8 @@ int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, while (--wr_count) i = i->next; *bad_wr = i; - } + } else if (ret) + *bad_wr = wr; return ret; } @@ -944,7 +945,8 @@ int ibv_cmd_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr, while (--wr_count) i = i->next; *bad_wr = i; - } + } else if (ret) + *bad_wr = wr; return ret; } @@ -1004,7 +1006,8 @@ int ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr, while (--wr_count) i = i->next; *bad_wr = i; - } + } else if (ret) + *bad_wr = wr; return ret; }