This should enable us to catch if we are initializing the namespace with a wrong
size.

Signed-off-by: Aneesh Kumar K.V <[email protected]>
---
 drivers/nvdimm/namespace_devs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 0e4c04765cb8..06b55c41660d 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -967,6 +967,18 @@ static void nd_namespace_pmem_set_resource(struct 
nd_region *nd_region,
  out:
        res->start = nd_region->ndr_start + offset;
        res->end = res->start + size - 1;
+#ifdef CONFIG_DEBUG_VM
+       if (size) {
+               unsigned long map_size;
+
+               map_size = nvdimm_validate_namespace_size(nd_region, size, 
arch_namespace_align_size());
+               WARN_ON(map_size);
+
+               map_size = nvdimm_validate_namespace_size(nd_region, 
res->start, arch_namespace_align_size());
+               WARN_ON(map_size);
+
+       }
+#endif
 }
 
 static bool uuid_not_set(const u8 *uuid, struct device *dev, const char *where)
-- 
2.23.0
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to