提交 503aef46 编写于 作者: T Tariq Toukan 提交者: Zheng Zengkai

net/tls: Check for errors in tls_device_init

stable inclusion
from stable-v5.10.132
commit c713de1d80a5d7035dc7f667b485bded83b4e74a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5YS3T

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c713de1d80a5d7035dc7f667b485bded83b4e74a

--------------------------------

[ Upstream commit 3d8c51b2 ]

Add missing error checks in tls_device_init.

Fixes: e8f69799 ("net/tls: Add generic NIC offload infrastructure")
Reported-by: NJakub Kicinski <kuba@kernel.org>
Reviewed-by: NMaxim Mikityanskiy <maximmi@nvidia.com>
Signed-off-by: NTariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/20220714070754.1428-1-tariqt@nvidia.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 4c0ad999
...@@ -722,7 +722,7 @@ int tls_sw_fallback_init(struct sock *sk, ...@@ -722,7 +722,7 @@ int tls_sw_fallback_init(struct sock *sk,
struct tls_crypto_info *crypto_info); struct tls_crypto_info *crypto_info);
#ifdef CONFIG_TLS_DEVICE #ifdef CONFIG_TLS_DEVICE
void tls_device_init(void); int tls_device_init(void);
void tls_device_cleanup(void); void tls_device_cleanup(void);
void tls_device_sk_destruct(struct sock *sk); void tls_device_sk_destruct(struct sock *sk);
int tls_set_device_offload(struct sock *sk, struct tls_context *ctx); int tls_set_device_offload(struct sock *sk, struct tls_context *ctx);
...@@ -742,7 +742,7 @@ static inline bool tls_is_sk_rx_device_offloaded(struct sock *sk) ...@@ -742,7 +742,7 @@ static inline bool tls_is_sk_rx_device_offloaded(struct sock *sk)
return tls_get_ctx(sk)->rx_conf == TLS_HW; return tls_get_ctx(sk)->rx_conf == TLS_HW;
} }
#else #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 void tls_device_cleanup(void) {}
static inline int static inline int
......
...@@ -1390,9 +1390,9 @@ static struct notifier_block tls_dev_notifier = { ...@@ -1390,9 +1390,9 @@ static struct notifier_block tls_dev_notifier = {
.notifier_call = tls_dev_event, .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) void __exit tls_device_cleanup(void)
......
...@@ -905,7 +905,12 @@ static int __init tls_register(void) ...@@ -905,7 +905,12 @@ static int __init tls_register(void)
if (err) if (err)
return 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); tcp_register_ulp(&tcp_tls_ulp_ops);
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册