nvmet-rdma: check for timeout in nvme_rdma_wait_for_cm()

Check whether queue->cm_error holds a value before reading it. This patch
addresses Coverity ID 1373774: unchecked return value.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Bart Van Assche 2018-10-08 14:28:54 -07:00 committed by Christoph Hellwig
parent 43a6f8fb61
commit 35da77d556
1 changed files with 8 additions and 1 deletions

View File

@ -233,8 +233,15 @@ static void nvme_rdma_qp_event(struct ib_event *event, void *context)
static int nvme_rdma_wait_for_cm(struct nvme_rdma_queue *queue)
{
wait_for_completion_interruptible_timeout(&queue->cm_done,
int ret;
ret = wait_for_completion_interruptible_timeout(&queue->cm_done,
msecs_to_jiffies(NVME_RDMA_CONNECT_TIMEOUT_MS) + 1);
if (ret < 0)
return ret;
if (ret == 0)
return -ETIMEDOUT;
WARN_ON_ONCE(queue->cm_error > 0);
return queue->cm_error;
}