mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dax: fix dax_core_init error return code
@ 2026-10-11 13:20 jianyungao89
  2026-10-12 14:21 ` Markus Elfring
  2026-10-12 14:28 ` Jonathan Cameron
  0 siblings, 2 replies; 4+ messages in thread
From: jianyungao89 @ 2026-10-11 13:20 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>

dax_core_init() mistakenly returns 0 on error paths. Change the
error return to use rc so the actual error code is propagated
to the caller.

Fixes: 9567da0b408a ("device-dax: Introduce bus + driver model")
Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
---
 drivers/dax/super.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 45f84b0eb909..0f35f65363ee 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -723,7 +723,7 @@ static int __init dax_core_init(void)
 
 	rc = dax_fs_init();
 	if (rc)
-		return rc;
+		goto err_fs;
 
 	rc = alloc_chrdev_region(&dax_devt, 0, MINORMASK+1, "dax");
 	if (rc)
@@ -738,7 +738,8 @@ static int __init dax_core_init(void)
 	unregister_chrdev_region(dax_devt, MINORMASK+1);
 err_chrdev:
 	dax_fs_exit();
-	return 0;
+err_fs:
+	return rc;
 }
 
 static void __exit dax_core_exit(void)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dax: fix dax_core_init error return code
  2026-10-11 13:20 [PATCH] dax: fix dax_core_init error return code jianyungao89
@ 2026-10-12 14:21 ` Markus Elfring
  2026-10-12 14:28 ` Jonathan Cameron
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2026-10-12 14:21 UTC (permalink / raw)
  To: Jianyun Gao, linux-cxl, nvdimm
  Cc: LKML, Alison Schofield, Dan Williams, Dave Jiang, Vishal Verma

> dax_core_init() mistakenly returns 0 on error paths. Change the
> error return to use rc so the actual error code is propagated
> to the caller.

Please reconsider the proposed need for an additional label once more.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v7.3-rc7#n532

Regards,
Markus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dax: fix dax_core_init error return code
  2026-10-11 13:20 [PATCH] dax: fix dax_core_init error return code jianyungao89
  2026-10-12 14:21 ` Markus Elfring
@ 2026-10-12 14:28 ` Jonathan Cameron
  2026-10-12 15:01   ` Jianyun Gao
  1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2026-10-12 14:28 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:20:17 +0800
jianyungao89@gmail.com wrote:

> From: Jianyun Gao <jianyungao89@gmail.com>
> 
> dax_core_init() mistakenly returns 0 on error paths. Change the
> error return to use rc so the actual error code is propagated
> to the caller.

What is the user visible impact of this failing?

> 
> Fixes: 9567da0b408a ("device-dax: Introduce bus + driver model")
> Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
> ---
>  drivers/dax/super.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dax/super.c b/drivers/dax/super.c
> index 45f84b0eb909..0f35f65363ee 100644
> --- a/drivers/dax/super.c
> +++ b/drivers/dax/super.c
> @@ -723,7 +723,7 @@ static int __init dax_core_init(void)
>  
>  	rc = dax_fs_init();
>  	if (rc)
> -		return rc;
> +		goto err_fs;
I don't see an advantage in this bit.  It is a fairly common preference
to error out directly where there is nothing to do.

>  
>  	rc = alloc_chrdev_region(&dax_devt, 0, MINORMASK+1, "dax");
>  	if (rc)
> @@ -738,7 +738,8 @@ static int __init dax_core_init(void)
>  	unregister_chrdev_region(dax_devt, MINORMASK+1);
>  err_chrdev:
>  	dax_fs_exit();
> -	return 0;
> +err_fs:
> +	return rc;
I'm not sure about this one.  Will need input from the DAX
folk on whether they were deliberately eating the error return
here. Not that I can immediately think of a reason to do so!

Jonathan


>  }
>  
>  static void __exit dax_core_exit(void)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dax: fix dax_core_init error return code
  2026-10-12 14:28 ` Jonathan Cameron
@ 2026-10-12 15:01   ` Jianyun Gao
  0 siblings, 0 replies; 4+ messages in thread
From: Jianyun Gao @ 2026-10-12 15:01 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-kernel, Dan Williams, Vishal Verma, Dave Jiang,
	Alison Schofield, open list:DEVICE DIRECT ACCESS (DAX),
	open list:DEVICE DIRECT ACCESS (DAX)

Hi Jonathan,

Thank you for the review!

For the goto err_fs change, I agree it's unnecessary since there's
nothing to clean up at that point. I will drop it in v2.

For the return 0 -> return rc change, I also can't think of a reason
to deliberately swallow the error. I'll keep this change and cc the
DAX maintainers for their input.

Best regards,
Jianyun

On Mon, Oct 12, 2026 at 10:28 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Sun, 11 Oct 2026 21:20:17 +0800
> jianyungao89@gmail.com wrote:
>
> > From: Jianyun Gao <jianyungao89@gmail.com>
> >
> > dax_core_init() mistakenly returns 0 on error paths. Change the
> > error return to use rc so the actual error code is propagated
> > to the caller.
>
> What is the user visible impact of this failing?
>
> >
> > Fixes: 9567da0b408a ("device-dax: Introduce bus + driver model")
> > Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
> > ---
> >  drivers/dax/super.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/dax/super.c b/drivers/dax/super.c
> > index 45f84b0eb909..0f35f65363ee 100644
> > --- a/drivers/dax/super.c
> > +++ b/drivers/dax/super.c
> > @@ -723,7 +723,7 @@ static int __init dax_core_init(void)
> >
> >       rc = dax_fs_init();
> >       if (rc)
> > -             return rc;
> > +             goto err_fs;
> I don't see an advantage in this bit.  It is a fairly common preference
> to error out directly where there is nothing to do.
>
> >
> >       rc = alloc_chrdev_region(&dax_devt, 0, MINORMASK+1, "dax");
> >       if (rc)
> > @@ -738,7 +738,8 @@ static int __init dax_core_init(void)
> >       unregister_chrdev_region(dax_devt, MINORMASK+1);
> >  err_chrdev:
> >       dax_fs_exit();
> > -     return 0;
> > +err_fs:
> > +     return rc;
> I'm not sure about this one.  Will need input from the DAX
> folk on whether they were deliberately eating the error return
> here. Not that I can immediately think of a reason to do so!
>
> Jonathan
>
>
> >  }
> >
> >  static void __exit dax_core_exit(void)
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-12 15:01 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:20 [PATCH] dax: fix dax_core_init error return code jianyungao89
2026-10-12 14:21 ` Markus Elfring
2026-10-12 14:28 ` Jonathan Cameron
2026-10-12 15:01   ` 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®