File daxctl-Fix-memblock-enumeration-off-by-one.patch of Package ndctl
From 06419eb6e8622baab05601e4c1007642b14dd4ef Mon Sep 17 00:00:00 2001
From: Dan Williams <dan.j.williams@intel.com>
Date: Thu, 2 Feb 2023 12:56:47 -0800
Subject: [PATCH] daxctl: Fix memblock enumeration off-by-one
Upstream: v76
Git-commit: 06419eb6e8622baab05601e4c1007642b14dd4ef
A memblock is an inclusive memory range. Bound the search by the last
address in the memory block.
Found by wondering why an offline 32-block (at 128MB == 4GB) range was
reported as 33 blocks with one online.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lore.kernel.org/r/167537140762.3268840.2926966718345830138.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
daxctl/lib/libdaxctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index 5703992..d990479 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -1477,7 +1477,7 @@ static int memblock_in_dev(struct daxctl_memory *mem, const char *memblock)
err(ctx, "%s: Unable to determine resource\n", devname);
return -EACCES;
}
- dev_end = dev_start + daxctl_dev_get_size(dev);
+ dev_end = dev_start + daxctl_dev_get_size(dev) - 1;
memblock_size = daxctl_memory_get_block_size(mem);
if (!memblock_size) {
--
2.39.1