aboutsummaryrefslogtreecommitdiff
path: root/hw/block
diff options
context:
space:
mode:
authorGollu Appalanaidu <anaidu.gollu@samsung.com>2020-10-22 14:37:08 +0530
committerKlaus Jensen <k.jensen@samsung.com>2020-10-27 11:29:25 +0100
commit843c8f91a7ad63f8f3e4e564d3f41f3d030ab8a9 (patch)
tree2bf77d39d0e912e21debee805fd2141691e62d47 /hw/block
parent482e97fcfad6672d2849f2fe36bd460d70468b0a (diff)
downloadqemu-843c8f91a7ad63f8f3e4e564d3f41f3d030ab8a9.zip
qemu-843c8f91a7ad63f8f3e4e564d3f41f3d030ab8a9.tar.gz
qemu-843c8f91a7ad63f8f3e4e564d3f41f3d030ab8a9.tar.bz2
hw/block/nvme: fix queue identifer validation
The nvme_check_{sq,cq} functions check if the given queue identifer is valid *and* that the queue exists. Thus, the function return value cannot simply be inverted to check if the identifer is valid and that the queue does *not* exist. Replace the call with an OR'ed version of the checks. Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com> Signed-off-by: Klaus Jensen <k.jensen@samsung.com> Reviewed-by: Keith Busch <kbusch@kernel.org>
Diffstat (limited to 'hw/block')
-rw-r--r--hw/block/nvme.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 5dfef02..fa2cba7 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1143,7 +1143,8 @@ static uint16_t nvme_create_sq(NvmeCtrl *n, NvmeRequest *req)
trace_pci_nvme_err_invalid_create_sq_cqid(cqid);
return NVME_INVALID_CQID | NVME_DNR;
}
- if (unlikely(!sqid || !nvme_check_sqid(n, sqid))) {
+ if (unlikely(!sqid || sqid > n->params.max_ioqpairs ||
+ n->sq[sqid] != NULL)) {
trace_pci_nvme_err_invalid_create_sq_sqid(sqid);
return NVME_INVALID_QID | NVME_DNR;
}
@@ -1398,7 +1399,8 @@ static uint16_t nvme_create_cq(NvmeCtrl *n, NvmeRequest *req)
trace_pci_nvme_create_cq(prp1, cqid, vector, qsize, qflags,
NVME_CQ_FLAGS_IEN(qflags) != 0);
- if (unlikely(!cqid || !nvme_check_cqid(n, cqid))) {
+ if (unlikely(!cqid || cqid > n->params.max_ioqpairs ||
+ n->cq[cqid] != NULL)) {
trace_pci_nvme_err_invalid_create_cq_cqid(cqid);
return NVME_INVALID_QID | NVME_DNR;
}