Netdev List
 help / color / mirror / Atom feed
* [PATCH] mctp: check register_netdevice_notifier() error in mctp_device_init()
@ 2026-07-13  7:39 Minhong He
  2026-07-15  0:37 ` Jeremy Kerr
  0 siblings, 1 reply; 5+ messages in thread
From: Minhong He @ 2026-07-13  7:39 UTC (permalink / raw)
  To: netdev; +Cc: Jeremy Kerr, Matt Johnston

mctp_device_init() handles errors from rtnl_af_register() and
rtnl_register_many(), but ignores the return value of
register_netdevice_notifier(). If notifier registration fails, init can
still return success while the module is only partially initialized.

Check the notifier registration error and fail module init early.

Fixes: d51705614f66 ("mctp: Handle error of rtnl_register_module().")

Signed-off-by: Minhong He <heminhong@kylinos.cn>
---
 net/mctp/device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/mctp/device.c b/net/mctp/device.c
index 2c84df674669..822120e860c8 100644
--- a/net/mctp/device.c
+++ b/net/mctp/device.c
@@ -536,7 +536,9 @@ int __init mctp_device_init(void)
 {
 	int err;
 
-	register_netdevice_notifier(&mctp_dev_nb);
+	err = register_netdevice_notifier(&mctp_dev_nb);
+	if (err)
+		return err;
 
 	err = rtnl_af_register(&mctp_af_ops);
 	if (err)
-- 
2.25.1


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

* Re: [PATCH] mctp: check register_netdevice_notifier() error in mctp_device_init()
  2026-07-13  7:39 [PATCH] mctp: check register_netdevice_notifier() error in mctp_device_init() Minhong He
@ 2026-07-15  0:37 ` Jeremy Kerr
  2026-07-16  6:35   ` [PATCH net v2] " Minhong He
  0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Kerr @ 2026-07-15  0:37 UTC (permalink / raw)
  To: Minhong He, netdev; +Cc: Matt Johnston

Hi,

> [PATCH] mctp: check register_netdevice_notifier() error in mctp_device_init()

Please include the target tree in the subject prefix. SInce this is for
the net tree, you want something like:

  [PATCH net] mctp: check ...

> mctp_device_init() handles errors from rtnl_af_register() and
> rtnl_register_many(), but ignores the return value of
> register_netdevice_notifier(). If notifier registration fails, init
> can still return success while the module is only partially initialized.
> 
> Check the notifier registration error and fail module init early.

The change itself looks good, thanks.

> Fixes: d51705614f66 ("mctp: Handle error of rtnl_register_module().")

... but no newline between the fixes and signed-off-by (and other tags).

Also, make sure you CC all the necessary maintainers; you're getting a
nipa CI failure due to that.

With those addressed:

Acked-by: Jeremy Kerr <jk@codeconstruct.com.au>

Cheers,


Jeremy

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

* [PATCH net v2] mctp: check register_netdevice_notifier() error in mctp_device_init()
  2026-07-15  0:37 ` Jeremy Kerr
@ 2026-07-16  6:35   ` Minhong He
  2026-07-16  7:32     ` Kuniyuki Iwashima
  0 siblings, 1 reply; 5+ messages in thread
From: Minhong He @ 2026-07-16  6:35 UTC (permalink / raw)
  To: jk; +Cc: heminhong, matt, netdev, davem, edumazet, kuba, pabeni, horms,
	kuniyu

mctp_device_init() handles errors from rtnl_af_register() and
rtnl_register_many(), but ignores the return value of
register_netdevice_notifier(). If notifier registration fails, init can
still return success while the module is only partially initialized.

Check the notifier registration error and fail module init early.

Fixes: d51705614f66 ("mctp: Handle error of rtnl_register_module().")
Signed-off-by: Minhong He <heminhong@kylinos.cn>
---
 net/mctp/device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/mctp/device.c b/net/mctp/device.c
index 2c84df674669..822120e860c8 100644
--- a/net/mctp/device.c
+++ b/net/mctp/device.c
@@ -536,7 +536,9 @@ int __init mctp_device_init(void)
 {
 	int err;
 
-	register_netdevice_notifier(&mctp_dev_nb);
+	err = register_netdevice_notifier(&mctp_dev_nb);
+	if (err)
+		return err;
 
 	err = rtnl_af_register(&mctp_af_ops);
 	if (err)
-- 
2.25.1


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

* Re: [PATCH net v2] mctp: check register_netdevice_notifier() error in mctp_device_init()
  2026-07-16  6:35   ` [PATCH net v2] " Minhong He
@ 2026-07-16  7:32     ` Kuniyuki Iwashima
  2026-07-16  7:53       ` Jeremy Kerr
  0 siblings, 1 reply; 5+ messages in thread
From: Kuniyuki Iwashima @ 2026-07-16  7:32 UTC (permalink / raw)
  To: Minhong He; +Cc: jk, matt, netdev, davem, edumazet, kuba, pabeni, horms

On Thu, Jul 16, 2026 at 8:35 AM Minhong He <heminhong@kylinos.cn> wrote:
>
> mctp_device_init() handles errors from rtnl_af_register() and
> rtnl_register_many(), but ignores the return value of
> register_netdevice_notifier(). If notifier registration fails, init can
> still return success while the module is only partially initialized.
>
> Check the notifier registration error and fail module init early.
>
> Fixes: d51705614f66 ("mctp: Handle error of rtnl_register_module().")

The bug predates the commit:

$ git blame -L:mctp_device_init net/mctp/device.c d51705614f668~



> Signed-off-by: Minhong He <heminhong@kylinos.cn>
> ---
>  net/mctp/device.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/mctp/device.c b/net/mctp/device.c
> index 2c84df674669..822120e860c8 100644
> --- a/net/mctp/device.c
> +++ b/net/mctp/device.c
> @@ -536,7 +536,9 @@ int __init mctp_device_init(void)
>  {
>         int err;
>
> -       register_netdevice_notifier(&mctp_dev_nb);
> +       err = register_netdevice_notifier(&mctp_dev_nb);
> +       if (err)
> +               return err;
>
>         err = rtnl_af_register(&mctp_af_ops);
>         if (err)
> --
> 2.25.1
>

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

* Re: [PATCH net v2] mctp: check register_netdevice_notifier() error in mctp_device_init()
  2026-07-16  7:32     ` Kuniyuki Iwashima
@ 2026-07-16  7:53       ` Jeremy Kerr
  0 siblings, 0 replies; 5+ messages in thread
From: Jeremy Kerr @ 2026-07-16  7:53 UTC (permalink / raw)
  To: Kuniyuki Iwashima, Minhong He
  Cc: matt, netdev, davem, edumazet, kuba, pabeni, horms

Hi all,

> > Fixes: d51705614f66 ("mctp: Handle error of rtnl_register_module().")
> 
> The bug predates the commit:
> 
> $ git blame -L:mctp_device_init net/mctp/device.c d51705614f668~

We could alter this to the original commit (before the error paths were
introduced), at 583be982d9347, but would also need to pull d51705614f66
as a prereq, or fix the conflicts with earlier stable backports.

This sounds sensible to me, but is a fairly unlikely error path in
general.

Cheers,


Jeremy

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

end of thread, other threads:[~2026-07-16  7:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13  7:39 [PATCH] mctp: check register_netdevice_notifier() error in mctp_device_init() Minhong He
2026-07-15  0:37 ` Jeremy Kerr
2026-07-16  6:35   ` [PATCH net v2] " Minhong He
2026-07-16  7:32     ` Kuniyuki Iwashima
2026-07-16  7:53       ` Jeremy Kerr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox