]> git.infradead.org Git - users/hch/misc.git/commitdiff
nvme: keyring: fix conditional compilation
authorHannes Reinecke <hare@suse.de>
Thu, 26 Oct 2023 13:08:04 +0000 (15:08 +0200)
committerKeith Busch <kbusch@kernel.org>
Wed, 8 Nov 2023 16:07:08 +0000 (08:07 -0800)
The keyring and auth functions can be called from both the host and
the target side and are controlled by Kconfig options for each of the
combinations, but the declarations are controlled by #ifdef checks
on the shared Kconfig symbols.

This leads to link failures in combinations where one of the frontends
is built-in and the other one is a module, and the keyring code
ends up in a module that is not reachable from the builtin code:

ld: drivers/nvme/host/core.o: in function `nvme_core_exit':
core.c:(.exit.text+0x4): undefined reference to `nvme_keyring_exit'
ld: drivers/nvme/host/core.o: in function `nvme_core_init':
core.c:(.init.text+0x94): undefined reference to `nvme_keyring_init

ld: drivers/nvme/host/tcp.o: in function `nvme_tcp_setup_ctrl':
tcp.c:(.text+0x4c18): undefined reference to `nvme_tls_psk_default'

Address this by moving nvme_keyring_init()/nvme_keyring_exit() into
module init/exit functions for the keyring module.

Fixes: be8e82caa6859 ("nvme-tcp: enable TLS handshake upcall")
Signed-off-by: Hannes Reinecke <hare@suse.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/common/keyring.c
drivers/nvme/host/core.c
include/linux/nvme-keyring.h

index 46d7a537dbc2eace5cde12f414b095c6c64a86d7..ee341b83eebaf553cbf91a045b048285d590157a 100644 (file)
@@ -151,7 +151,7 @@ key_serial_t nvme_tls_psk_default(struct key *keyring,
 }
 EXPORT_SYMBOL_GPL(nvme_tls_psk_default);
 
-int nvme_keyring_init(void)
+static int __init nvme_keyring_init(void)
 {
        int err;
 
@@ -171,14 +171,15 @@ int nvme_keyring_init(void)
        }
        return 0;
 }
-EXPORT_SYMBOL_GPL(nvme_keyring_init);
 
-void nvme_keyring_exit(void)
+static void __exit nvme_keyring_exit(void)
 {
        unregister_key_type(&nvme_tls_psk_key_type);
        key_revoke(nvme_keyring);
        key_put(nvme_keyring);
 }
-EXPORT_SYMBOL_GPL(nvme_keyring_exit);
 
 MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Hannes Reinecke <hare@suse.de>");
+module_init(nvme_keyring_init);
+module_exit(nvme_keyring_exit);
index 75a1b58a7a436fdac43945d0ded8ea989224cf3c..88b54cdcbd683cd3e7f0a26742aff156ad4c57b5 100644 (file)
@@ -25,7 +25,6 @@
 #include "nvme.h"
 #include "fabrics.h"
 #include <linux/nvme-auth.h>
-#include <linux/nvme-keyring.h>
 
 #define CREATE_TRACE_POINTS
 #include "trace.h"
@@ -4737,16 +4736,11 @@ static int __init nvme_core_init(void)
                result = PTR_ERR(nvme_ns_chr_class);
                goto unregister_generic_ns;
        }
-       result = nvme_keyring_init();
-       if (result)
-               goto destroy_ns_chr;
        result = nvme_init_auth();
        if (result)
-               goto keyring_exit;
+               goto destroy_ns_chr;
        return 0;
 
-keyring_exit:
-       nvme_keyring_exit();
 destroy_ns_chr:
        class_destroy(nvme_ns_chr_class);
 unregister_generic_ns:
@@ -4770,7 +4764,6 @@ out:
 static void __exit nvme_core_exit(void)
 {
        nvme_exit_auth();
-       nvme_keyring_exit();
        class_destroy(nvme_ns_chr_class);
        class_destroy(nvme_subsys_class);
        class_destroy(nvme_class);
index 6cc0696625f36181fb1d9a271a67cb2f9cdb6376..e10333d78dbbe539f3011a85d5e221d102560c99 100644 (file)
@@ -12,8 +12,6 @@ key_serial_t nvme_tls_psk_default(struct key *keyring,
                const char *hostnqn, const char *subnqn);
 
 key_serial_t nvme_keyring_id(void);
-int nvme_keyring_init(void);
-void nvme_keyring_exit(void);
 
 #else
 
@@ -26,11 +24,5 @@ static inline key_serial_t nvme_keyring_id(void)
 {
        return 0;
 }
-static inline int nvme_keyring_init(void)
-{
-       return 0;
-}
-static inline void nvme_keyring_exit(void) {}
-
 #endif /* !CONFIG_NVME_KEYRING */
 #endif /* _NVME_KEYRING_H */