mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-29 13:23:23 +01:00
can: raw: process optimization in raw_init()
Now, register notifier after register proto successfully. It can create raw socket and set socket options once register proto successfully, so it is possible missing notifier event before register notifier successfully although this is a low probability scenario. Move notifier registration to the front of proto registration like done in j1939. In addition, register_netdevice_notifier() may fail, check its result is necessary. Signed-off-by: Ziyang Xuan <[email protected]> Link: https://lore.kernel.org/all/7af9401f0d2d9fed36c1667b5ac9b8df8f8b87ee.1661584485.git.william.xuanziyang@huawei.com Signed-off-by: Marc Kleine-Budde <[email protected]>
This commit is contained in:
1 parent
318d8235bc
commit
c28b3bffe4
1 file changed
+13
-5
+13
-5
@@ -942,12 +942,20 @@ static __init int raw_module_init(void)
|
||||
|
||||
pr_info("can: raw protocol\n");
|
||||
|
||||
err = can_proto_register(&raw_can_proto);
|
||||
if (err < 0)
|
||||
pr_err("can: registration of raw protocol failed\n");
|
||||
else
|
||||
register_netdevice_notifier(&canraw_notifier);
|
||||
err = register_netdevice_notifier(&canraw_notifier);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = can_proto_register(&raw_can_proto);
|
||||
if (err < 0) {
|
||||
pr_err("can: registration of raw protocol failed\n");
|
||||
goto register_proto_failed;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
register_proto_failed:
|
||||
unregister_netdevice_notifier(&canraw_notifier);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user