mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
dax/bus: Return errors for invalid mapping targets
After the DAX configuration locking was converted to rwsems, successful
lock acquisition leaves rc set to zero in mapping_store(). Two error
paths can return this stale value: an unbound region driver and a
misaligned range size. The sysfs write therefore reports success without
allocating the requested range.
Return -ENXIO when the region driver is not bound and -EINVAL when the
range size is misaligned.
Fixes: c05ae9d85b ("dax/bus.c: replace driver-core lock usage by a local rwsem")
Assisted-by: LLM
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jianyun Gao <jianyungao89@gmail.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://patch.msgid.link/20260924025035.1265035-2-songmuchun@bytedance.com
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
This commit is contained in:
parent
a4bfbfb4e9
commit
df6cc0a247
|
|
@ -1192,7 +1192,7 @@ static ssize_t mapping_store(struct device *dev, struct device_attribute *attr,
|
|||
return rc;
|
||||
if (!dax_region->dev->driver) {
|
||||
up_write(&dax_region_rwsem);
|
||||
return rc;
|
||||
return -ENXIO;
|
||||
}
|
||||
rc = down_write_killable(&dax_dev_rwsem);
|
||||
if (rc) {
|
||||
|
|
@ -1201,8 +1201,12 @@ static ssize_t mapping_store(struct device *dev, struct device_attribute *attr,
|
|||
}
|
||||
|
||||
to_alloc = range_len(&r);
|
||||
if (alloc_is_aligned(dev_dax, to_alloc))
|
||||
if (!alloc_is_aligned(dev_dax, to_alloc)) {
|
||||
dev_dbg(dev, "%s: size: %zu misaligned\n", __func__, to_alloc);
|
||||
rc = -EINVAL;
|
||||
} else {
|
||||
rc = alloc_dev_dax_range(dev_dax, r.start, to_alloc);
|
||||
}
|
||||
up_write(&dax_dev_rwsem);
|
||||
up_write(&dax_region_rwsem);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user