summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Groves <John@Groves.net>2026-06-15 16:07:21 +0000
committerAlison Schofield <alison.schofield@intel.com>2026-07-14 16:26:43 -0700
commit755effecd6fc7d8ff18f09135cb5e3cf98c20d55 (patch)
treee19bbbc1cf598b61217bf0ae7547009febf3c133
parentff7c73fca793bd5c29a15ba735b0886f62f3a840 (diff)
dax/fsdev: fail probe on invalid pgmap offset
Convert the WARN_ON to a fatal error when pgmap_phys > phys. This condition means the remapped region starts after the device's data region, which is an impossible state. Previously the probe continued with data_offset=0, leaving virt_addr silently misaligned. Now probe returns -EINVAL with a diagnostic message. Fixes: 759455848df0b ("dax: Save the kva from memremap") Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com> Signed-off-by: John Groves <john@groves.net> Link: https://patch.msgid.link/0100019ecc0999fa-97574544-8b6b-46cf-9f33-423abdbeee7f-000000@email.amazonses.com Signed-off-by: Alison Schofield <alison.schofield@intel.com>
-rw-r--r--drivers/dax/fsdev.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/dax/fsdev.c b/drivers/dax/fsdev.c
index 57c589e19b53..d50891d6dc13 100644
--- a/drivers/dax/fsdev.c
+++ b/drivers/dax/fsdev.c
@@ -342,8 +342,12 @@ static int fsdev_dax_probe(struct dev_dax *dev_dax)
u64 phys = dev_dax->ranges[0].range.start;
u64 pgmap_phys = pgmap[0].range.start;
- if (!WARN_ON(pgmap_phys > phys))
- data_offset = phys - pgmap_phys;
+ if (pgmap_phys > phys) {
+ dev_err(dev, "pgmap start %#llx exceeds data start %#llx\n",
+ pgmap_phys, phys);
+ return -EINVAL;
+ }
+ data_offset = phys - pgmap_phys;
pr_debug("%s: offset detected phys=%llx pgmap_phys=%llx offset=%llx\n",
__func__, phys, pgmap_phys, data_offset);