Skip to content

Commit 8b878ee

Browse files
committed
Merge branch 'nvme-4.20' of git://git.infradead.org/nvme into for-linus
Pull NVMe fixes from Christoph. * 'nvme-4.20' of git://git.infradead.org/nvme: nvmet-rdma: fix response use after free nvme: validate controller state before rescheduling keep alive
2 parents c616cbe + d7dcdf9 commit 8b878ee

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

drivers/nvme/host/core.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,8 @@ static int nvme_submit_user_cmd(struct request_queue *q,
831831
static void nvme_keep_alive_end_io(struct request *rq, blk_status_t status)
832832
{
833833
struct nvme_ctrl *ctrl = rq->end_io_data;
834+
unsigned long flags;
835+
bool startka = false;
834836

835837
blk_mq_free_request(rq);
836838

@@ -841,7 +843,13 @@ static void nvme_keep_alive_end_io(struct request *rq, blk_status_t status)
841843
return;
842844
}
843845

844-
schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ);
846+
spin_lock_irqsave(&ctrl->lock, flags);
847+
if (ctrl->state == NVME_CTRL_LIVE ||
848+
ctrl->state == NVME_CTRL_CONNECTING)
849+
startka = true;
850+
spin_unlock_irqrestore(&ctrl->lock, flags);
851+
if (startka)
852+
schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ);
845853
}
846854

847855
static int nvme_keep_alive(struct nvme_ctrl *ctrl)

drivers/nvme/target/rdma.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,15 @@ static void nvmet_rdma_send_done(struct ib_cq *cq, struct ib_wc *wc)
529529
{
530530
struct nvmet_rdma_rsp *rsp =
531531
container_of(wc->wr_cqe, struct nvmet_rdma_rsp, send_cqe);
532+
struct nvmet_rdma_queue *queue = cq->cq_context;
532533

533534
nvmet_rdma_release_rsp(rsp);
534535

535536
if (unlikely(wc->status != IB_WC_SUCCESS &&
536537
wc->status != IB_WC_WR_FLUSH_ERR)) {
537538
pr_err("SEND for CQE 0x%p failed with status %s (%d).\n",
538539
wc->wr_cqe, ib_wc_status_msg(wc->status), wc->status);
539-
nvmet_rdma_error_comp(rsp->queue);
540+
nvmet_rdma_error_comp(queue);
540541
}
541542
}
542543

0 commit comments

Comments
 (0)