* [PATCH] dax: fix mapping_store() returning 0 instead of error code
@ 2026-10-11 13:18 jianyungao89
2026-10-12 14:48 ` Jonathan Cameron
2026-10-12 23:21 ` Alison Schofield
0 siblings, 2 replies; 4+ messages in thread
From: jianyungao89 @ 2026-10-11 13:18 UTC (permalink / raw)
To: linux-kernel
Cc: Jianyun Gao, Dan Williams, Vishal Verma, Dave Jiang,
Alison Schofield, open list:DEVICE DIRECT ACCESS (DAX),
open list:DEVICE DIRECT ACCESS (DAX)
From: Jianyun Gao <jianyungao89@gmail.com>
When the region driver is not loaded, mapping_store() returns rc
which is 0 at that point, instead of an error code. Set it to
-ENXIO to match the equivalent check in size_store().
Fixes: 9567da0b408a ("device-dax: Introduce bus + driver model")
Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
---
drivers/dax/bus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index b809e1a264af..262f97b5e7aa 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -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) {
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dax: fix mapping_store() returning 0 instead of error code
2026-10-11 13:18 [PATCH] dax: fix mapping_store() returning 0 instead of error code jianyungao89
@ 2026-10-12 14:48 ` Jonathan Cameron
2026-10-12 23:21 ` Alison Schofield
1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2026-10-12 14:48 UTC (permalink / raw)
To: jianyungao89
Cc: linux-kernel, Dan Williams, Vishal Verma, Dave Jiang,
Alison Schofield, open list:DEVICE DIRECT ACCESS (DAX),
open list:DEVICE DIRECT ACCESS (DAX)
On Sun, 11 Oct 2026 21:18:57 +0800
jianyungao89@gmail.com wrote:
> From: Jianyun Gao <jianyungao89@gmail.com>
>
> When the region driver is not loaded, mapping_store() returns rc
> which is 0 at that point, instead of an error code. Set it to
> -ENXIO to match the equivalent check in size_store().
>
> Fixes: 9567da0b408a ("device-dax: Introduce bus + driver model")
> Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
Looks correct to me.
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
I'm curious, found by inspection or some tool?
J
> ---
> drivers/dax/bus.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> index b809e1a264af..262f97b5e7aa 100644
> --- a/drivers/dax/bus.c
> +++ b/drivers/dax/bus.c
> @@ -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) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dax: fix mapping_store() returning 0 instead of error code
2026-10-11 13:18 [PATCH] dax: fix mapping_store() returning 0 instead of error code jianyungao89
2026-10-12 14:48 ` Jonathan Cameron
@ 2026-10-12 23:21 ` Alison Schofield
2026-10-13 1:55 ` Jianyun Gao
1 sibling, 1 reply; 4+ messages in thread
From: Alison Schofield @ 2026-10-12 23:21 UTC (permalink / raw)
To: jianyungao89
Cc: linux-kernel, Dan Williams, Vishal Verma, Dave Jiang,
open list:DEVICE DIRECT ACCESS (DAX),
open list:DEVICE DIRECT ACCESS (DAX)
On Sun, Oct 11, 2026 at 09:18:57PM +0800, jianyungao89@gmail.com wrote:
> From: Jianyun Gao <jianyungao89@gmail.com>
>
> When the region driver is not loaded, mapping_store() returns rc
> which is 0 at that point, instead of an error code. Set it to
> -ENXIO to match the equivalent check in size_store().
Hi Jianyun,
The change looks correct, but there is another path in mapping_store() with
the same problem. When alloc_is_aligned() fails, rc is still zero, so the
sysfs write reports success without allocating the requested range.
Muchun Song already posted a patch addressing both cases.
https://lore.kernel.org/nvdimm/20260924025035.1265035-1-songmuchun@bytedance.com/
Please take a look and add your reviewed-by tag to Muchun's patchset
or comment if it doesn't meet your needs.
-- Alison
>
> Fixes: 9567da0b408a ("device-dax: Introduce bus + driver model")
> Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
> ---
> drivers/dax/bus.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> index b809e1a264af..262f97b5e7aa 100644
> --- a/drivers/dax/bus.c
> +++ b/drivers/dax/bus.c
> @@ -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) {
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dax: fix mapping_store() returning 0 instead of error code
2026-10-12 23:21 ` Alison Schofield
@ 2026-10-13 1:55 ` Jianyun Gao
0 siblings, 0 replies; 4+ messages in thread
From: Jianyun Gao @ 2026-10-13 1:55 UTC (permalink / raw)
To: Alison Schofield
Cc: linux-kernel, Dan Williams, Vishal Verma, Dave Jiang,
open list:DEVICE DIRECT ACCESS (DAX),
open list:DEVICE DIRECT ACCESS (DAX)
Hi Alison,
Thank you for pointing this out! I'll drop my patch since Muchun's
version covers both cases. I'll review Muchun's patch and add my
Reviewed-by if it looks good.
Best regards,
Jianyun
On Tue, Oct 13, 2026 at 7:21 AM Alison Schofield
<alison.schofield@intel.com> wrote:
>
> On Sun, Oct 11, 2026 at 09:18:57PM +0800, jianyungao89@gmail.com wrote:
> > From: Jianyun Gao <jianyungao89@gmail.com>
> >
> > When the region driver is not loaded, mapping_store() returns rc
> > which is 0 at that point, instead of an error code. Set it to
> > -ENXIO to match the equivalent check in size_store().
>
>
> Hi Jianyun,
>
> The change looks correct, but there is another path in mapping_store() with
> the same problem. When alloc_is_aligned() fails, rc is still zero, so the
> sysfs write reports success without allocating the requested range.
>
> Muchun Song already posted a patch addressing both cases.
> https://lore.kernel.org/nvdimm/20260924025035.1265035-1-songmuchun@bytedance.com/
>
> Please take a look and add your reviewed-by tag to Muchun's patchset
> or comment if it doesn't meet your needs.
>
> -- Alison
>
> >
> > Fixes: 9567da0b408a ("device-dax: Introduce bus + driver model")
> > Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
> > ---
> > drivers/dax/bus.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> > index b809e1a264af..262f97b5e7aa 100644
> > --- a/drivers/dax/bus.c
> > +++ b/drivers/dax/bus.c
> > @@ -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) {
> > --
> > 2.34.1
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-13 1:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-11 13:18 [PATCH] dax: fix mapping_store() returning 0 instead of error code jianyungao89
2026-10-12 14:48 ` Jonathan Cameron
2026-10-12 23:21 ` Alison Schofield
2026-10-13 1:55 ` Jianyun Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®