Message ID | 20190305232427.21530-3-dann.frazier@canonical.com |
---|---|
State | New |
Headers | show |
Series | [SRU,Cosmic] nvme-pci: fix out of bounds access in nvme_cqe_pending | expand |
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index feac4fef26c57..697ddbb400639 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -980,9 +980,11 @@ static void nvme_complete_cqes(struct nvme_queue *nvmeq, u16 start, u16 end) static inline void nvme_update_cq_head(struct nvme_queue *nvmeq) { - if (++nvmeq->cq_head == nvmeq->q_depth) { + if (nvmeq->cq_head == nvmeq->q_depth - 1) { nvmeq->cq_head = 0; nvmeq->cq_phase = !nvmeq->cq_phase; + } else { + nvmeq->cq_head++; } }