Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4372775imw; Tue, 19 Jul 2022 05:33:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sq0pkGeY6JuBy8UYyDeIPBUWBppRslE/2fLgpxqgBQuQiFwOmAR6DEkIQMuQh3rN53RacM X-Received: by 2002:a17:90a:5514:b0:1f1:f37f:ecc1 with SMTP id b20-20020a17090a551400b001f1f37fecc1mr4671121pji.70.1658234009620; Tue, 19 Jul 2022 05:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658234009; cv=none; d=google.com; s=arc-20160816; b=GG7Ajh8tBc/nbgQTEofDWn0OwvXMghgEnc2jl9RO2IsrltwbKKkzHrdrWzM5yA0+Ke Mxg+rK/rU/SsYpT1A8CoZReLcqMeE+g5YqcXrDPat6ShWUmEa/ndy1kY4vpOq5WruEee UarvjL1f/XK6ckJKt5fyhjp6MnULxgroxWcOqJv46hW2SPLn+7ZhAZMo/4Cyc4uOBToC h5EII9yTVGqB16nxR8dha1cefz9xDdVYsLnKEoZiNzYNVWgFz4tmPRIqNtFIBY/WtkzW kGcZ0KUMPGo99X0IkBF5eRbdDMIggJhjquTtX5rgO+0A9R/FlhiUTD0tVDrKrcr5CfRm Moyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GR1DL+OCmw7czFo4BzglMHdN/Er/aOJO9W9Ds4tzvYs=; b=QOq+h0YNoRilgaTmXA/s7kFQebTzn37y0O9Mh3TWraaKXls+QtExfe5waG8MBpjY01 Ya3mz2s/d2d/LUUnqEkmzdJh2ivyX5eTXOfgVlpwfdP4veWpGNOKxRkj9DPU/LljS6gO Iv2Fk9ePcHewbOdA/LvHzMs23hFt957pYXxD9vYZzPVfluSXGhF6cYEH3EYHbsc8bIIP MOIz6N8l/D8tgKyjlv/4md8OvmqZuQXzWAMWfLEK+wzge6clvU8hcvuin//WO4KS6DR0 0J2lkKn+R4op3dlHjgfNkpaRHT7xxBf2ucYBJteptjgVb8jifJ1T4WY/xGg43bCs0hkw QvvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=delM+iJ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t2-20020a62d142000000b0052ac145e8ebsi16743165pfl.83.2022.07.19.05.33.14; Tue, 19 Jul 2022 05:33:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=delM+iJ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239331AbiGSMZB (ORCPT + 99 others); Tue, 19 Jul 2022 08:25:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238949AbiGSMXr (ORCPT ); Tue, 19 Jul 2022 08:23:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5482A606A5; Tue, 19 Jul 2022 05:08:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 42708B81B1C; Tue, 19 Jul 2022 12:08:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 928D2C341C6; Tue, 19 Jul 2022 12:08:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232488; bh=Y+lUVQDFCey4mekk/3U0yLuh7J5RkZEDaFJu9ImxkHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=delM+iJ4SwWYuvwSdHwDvkXunYujVINQog5XRCKkby2M86LzK0MGg2A6gxk/mNoYb Gplg3/FpMg4L4QFxa4PR635fE/G3zT2gn0tAz9FzY+GCIVq0vd2MVEClJRnf19lHNO YFNs4LBRMb9X7jsSQ6J+VAY6tJlnlh+RBuQwyf/k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Kicinski , Maxim Mikityanskiy , Tariq Toukan , Sasha Levin Subject: [PATCH 5.10 075/112] net/tls: Check for errors in tls_device_init Date: Tue, 19 Jul 2022 13:54:08 +0200 Message-Id: <20220719114633.755436171@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tariq Toukan [ Upstream commit 3d8c51b25a235e283e37750943bbf356ef187230 ] Add missing error checks in tls_device_init. Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure") Reported-by: Jakub Kicinski Reviewed-by: Maxim Mikityanskiy Signed-off-by: Tariq Toukan Link: https://lore.kernel.org/r/20220714070754.1428-1-tariqt@nvidia.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- include/net/tls.h | 4 ++-- net/tls/tls_device.c | 4 ++-- net/tls/tls_main.c | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/net/tls.h b/include/net/tls.h index 745b3bc6ce91..d9cb597cab46 100644 --- a/include/net/tls.h +++ b/include/net/tls.h @@ -707,7 +707,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); @@ -727,7 +727,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 diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index 3c82286e5bcc..6ae2ce411b4b 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -1390,9 +1390,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) diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index 58d22d6b86ae..e537085b184f 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -905,7 +905,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; -- 2.35.1