qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] hw/block/nvme: slba equal to nsze is out of bounds if nlb is 1-b


From: Gollu Appalanaidu
Subject: [PATCH] hw/block/nvme: slba equal to nsze is out of bounds if nlb is 1-based
Date: Fri, 9 Apr 2021 13:14:02 +0530

NSZE is the total size of the namespace in logical blocks. So the max
addressable logical block is NLB minus 1. So your starting logical
block is equal to NSZE it is a out of range.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
---
 hw/block/nvme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 953ec64729..be9edb1158 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -2527,7 +2527,7 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)
             uint64_t slba = le64_to_cpu(range[i].slba);
             uint32_t nlb = le32_to_cpu(range[i].nlb);
 
-            if (nvme_check_bounds(ns, slba, nlb)) {
+            if (nvme_check_bounds(ns, slba, nlb) || slba == ns->id_ns.nsze) {
                 trace_pci_nvme_err_invalid_lba_range(slba, nlb,
                                                      ns->id_ns.nsze);
                 continue;
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]