diff mbox series

[net-next,01/11] can: bcm: registration process optimization in bcm_module_init()

Message ID 20220923120859.740577-2-mkl@pengutronix.de (mailing list archive)
State Accepted
Commit edd1a7e42f1d2d09c5f79ecef05ae19dc669bf34
Delegated to: Netdev Maintainers
Headers show
Series [net-next,01/11] can: bcm: registration process optimization in bcm_module_init() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Pull request is its own cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: edumazet@google.com pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 30 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Marc Kleine-Budde Sept. 23, 2022, 12:08 p.m. UTC
From: Ziyang Xuan <william.xuanziyang@huawei.com>

Now, register_netdevice_notifier() and register_pernet_subsys() are both
after can_proto_register(). It can create CAN_BCM socket and process socket
once can_proto_register() successfully, so it is possible missing notifier
event or proc node creation because notifier or bcm proc directory is not
registered or created yet. Although this is a low probability scenario, it
is not impossible.

Move register_pernet_subsys() and register_netdevice_notifier() to the
front of can_proto_register(). In addition, register_pernet_subsys() and
register_netdevice_notifier() may fail, check their results are necessary.

Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Link: https://lore.kernel.org/all/823cff0ebec33fa9389eeaf8b8ded3217c32cb38.1663206163.git.william.xuanziyang@huawei.com
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/bcm.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)


base-commit: d05d9eb79d0cd0f7a978621b4a56a1f2db444f86

Comments

patchwork-bot+netdevbpf@kernel.org Sept. 23, 2022, 2:20 p.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (master)
by Marc Kleine-Budde <mkl@pengutronix.de>:

On Fri, 23 Sep 2022 14:08:49 +0200 you wrote:
> From: Ziyang Xuan <william.xuanziyang@huawei.com>
> 
> Now, register_netdevice_notifier() and register_pernet_subsys() are both
> after can_proto_register(). It can create CAN_BCM socket and process socket
> once can_proto_register() successfully, so it is possible missing notifier
> event or proc node creation because notifier or bcm proc directory is not
> registered or created yet. Although this is a low probability scenario, it
> is not impossible.
> 
> [...]

Here is the summary with links:
  - [net-next,01/11] can: bcm: registration process optimization in bcm_module_init()
    https://git.kernel.org/netdev/net-next/c/edd1a7e42f1d
  - [net-next,02/11] can: bcm: check the result of can_send() in bcm_can_tx()
    https://git.kernel.org/netdev/net-next/c/3fd7bfd28cfd
  - [net-next,03/11] can: gs_usb: gs_usb_get_timestamp(): fix endpoint parameter for usb_control_msg_recv()
    https://git.kernel.org/netdev/net-next/c/593b5e2f5a4a
  - [net-next,04/11] can: gs_usb: add missing lock to protect struct timecounter::cycle_last
    https://git.kernel.org/netdev/net-next/c/29a8c9ec9090
  - [net-next,05/11] can: gs_usb: gs_can_open(): initialize time counter before starting device
    https://git.kernel.org/netdev/net-next/c/103108cb9673
  - [net-next,06/11] can: gs_usb: gs_cmd_reset(): rename variable holding struct gs_can pointer to dev
    https://git.kernel.org/netdev/net-next/c/002467518688
  - [net-next,07/11] can: gs_usb: convert from usb_control_msg() to usb_control_msg_{send,recv}()
    https://git.kernel.org/netdev/net-next/c/3814ed27548a
  - [net-next,08/11] can: gs_usb: gs_make_candev(): clean up error handling
    https://git.kernel.org/netdev/net-next/c/68822f4e74f3
  - [net-next,09/11] can: gs_usb: add switchable termination support
    https://git.kernel.org/netdev/net-next/c/906e0e6886af
  - [net-next,10/11] can: gs_usb: remove dma allocations
    https://git.kernel.org/netdev/net-next/c/62f102c0d156
  - [net-next,11/11] can: ctucanfd: Remove redundant dev_err call
    https://git.kernel.org/netdev/net-next/c/6eed756408c6

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/can/bcm.c b/net/can/bcm.c
index e5d179ba6f7d..0a2adb844280 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -1749,15 +1749,27 @@  static int __init bcm_module_init(void)
 
 	pr_info("can: broadcast manager protocol\n");
 
+	err = register_pernet_subsys(&canbcm_pernet_ops);
+	if (err)
+		return err;
+
+	err = register_netdevice_notifier(&canbcm_notifier);
+	if (err)
+		goto register_notifier_failed;
+
 	err = can_proto_register(&bcm_can_proto);
 	if (err < 0) {
 		printk(KERN_ERR "can: registration of bcm protocol failed\n");
-		return err;
+		goto register_proto_failed;
 	}
 
-	register_pernet_subsys(&canbcm_pernet_ops);
-	register_netdevice_notifier(&canbcm_notifier);
 	return 0;
+
+register_proto_failed:
+	unregister_netdevice_notifier(&canbcm_notifier);
+register_notifier_failed:
+	unregister_pernet_subsys(&canbcm_pernet_ops);
+	return err;
 }
 
 static void __exit bcm_module_exit(void)