]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/tls: Check for errors in tls_device_init
authorTariq Toukan <tariqt@nvidia.com>
Thu, 14 Jul 2022 07:07:54 +0000 (10:07 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 14 Jul 2022 17:12:39 +0000 (10:12 -0700)
Add missing error checks in tls_device_init.

Fixes: e31ec02c9978 ("net/tls: Add generic NIC offload infrastructure")
Reported-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/20220714070754.1428-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/tls.h
net/tls/tls_device.c
net/tls/tls_main.c

index 8017f1703447c1abbf48d9f7865b7427b7a2f81d..8bd938f98bdd8fa0f21d173763904c573239f4dc 100644 (file)
@@ -704,7 +704,7 @@ int tls_sw_fallback_init(struct sock *sk,
                         struct tls_crypto_info *crypto_info);
 
 #ifdef CONFIG_TLS_DEVICE
-void tls_device_init(void);
+int tls_device_init(void);
 void tls_device_cleanup(void);
 void tls_device_sk_destruct(struct sock *sk);
 int tls_set_device_offload(struct sock *sk, struct tls_context *ctx);
@@ -724,7 +724,7 @@ static inline bool tls_is_sk_rx_device_offloaded(struct sock *sk)
        return tls_get_ctx(sk)->rx_conf == TLS_HW;
 }
 #else
-static inline void tls_device_init(void) {}
+static inline int tls_device_init(void) { return 0; }
 static inline void tls_device_cleanup(void) {}
 
 static inline int
index ec6f4b699a2b32397e07c6afd025587476881eec..ce827e79c66a41d46333efbffd1c57ebf825ee03 100644 (file)
@@ -1419,9 +1419,9 @@ static struct notifier_block tls_dev_notifier = {
        .notifier_call  = tls_dev_event,
 };
 
-void __init tls_device_init(void)
+int __init tls_device_init(void)
 {
-       register_netdevice_notifier(&tls_dev_notifier);
+       return register_netdevice_notifier(&tls_dev_notifier);
 }
 
 void __exit tls_device_cleanup(void)
index 2ffede463e4a5c13fdb01de4a79fee98fd8d6b98..d80ab3d1764e7b6d36bb8dc3d151e2e89cf00f5b 100644 (file)
@@ -1048,7 +1048,12 @@ static int __init tls_register(void)
        if (err)
                return err;
 
-       tls_device_init();
+       err = tls_device_init();
+       if (err) {
+               unregister_pernet_subsys(&tls_proc_ops);
+               return err;
+       }
+
        tcp_register_ulp(&tcp_tls_ulp_ops);
 
        return 0;