diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c
index 565661abceb7568ee6e4d655c0e969aff6bf33ab..42a456f7706aa553d3dfb14d42a24fac7fa91057 100644
--- a/lustre/ptlrpc/client.c
+++ b/lustre/ptlrpc/client.c
@@ -2083,8 +2083,8 @@ repeat:
                   "-- sleeping for "CFS_DURATION_T" ticks", timeout);
         lwi = LWI_TIMEOUT_INTR(timeout, expired_request, interrupted_request,
                                req);
-        rc = l_wait_event(req->rq_reply_waitq, ptlrpc_check_reply(req), &lwi);
-        if (rc == -ETIMEDOUT && ((req->rq_deadline > cfs_time_current_sec()) ||
+        brc = l_wait_event(req->rq_reply_waitq, ptlrpc_check_reply(req), &lwi);
+        if (brc == -ETIMEDOUT && ((req->rq_deadline > cfs_time_current_sec()) ||
                                  ptlrpc_check_and_wait_suspend(req)))
                 goto repeat;
 
@@ -2109,7 +2109,7 @@ after_send:
         if (req->rq_err) {
                 DEBUG_REQ(D_RPCTRACE, req, "err rc=%d status=%d",
                           rc, req->rq_status);
-                GOTO(out, rc = -EIO);
+                GOTO(out, rc = rc ? rc : -EIO);
         }
 
         if (req->rq_intr) {
diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c
index 6d4226ddf007712868a2009d70a962743dffb13c..c83c8772a725536acaff3fd66c81321b0345a4f0 100644
--- a/lustre/ptlrpc/niobuf.c
+++ b/lustre/ptlrpc/niobuf.c
@@ -490,6 +490,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
                        request->rq_import->imp_obd->obd_name);
                 /* this prevents us from waiting in ptlrpc_queue_wait */
                 request->rq_err = 1;
+                request->rq_status = -ENODEV;
                 RETURN(-ENODEV);
         }
 
@@ -521,8 +522,13 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
                         LASSERT(request->rq_repmsg == NULL);
                         rc = sptlrpc_cli_alloc_repbuf(request,
                                                       request->rq_replen);
-                        if (rc)
+                        if (rc) {
+                                /* this prevents us from looping in
+                                 * ptlrpc_queue_wait */
+                                request->rq_err = 1;
+                                request->rq_status = rc;
                                 GOTO(cleanup_bulk, rc);
+                        }
                 } else {
                         request->rq_repdata = NULL;
                         request->rq_repmsg = NULL;