Skip to content

Commit 706add1

Browse files
hreineckekeithbusch
authored andcommitted
nvme: keyring: fix conditional compilation
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: be8e82c ("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>
1 parent 6affe08 commit 706add1

File tree

3 files changed

+6
-20
lines changed

3 files changed

+6
-20
lines changed

drivers/nvme/common/keyring.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ key_serial_t nvme_tls_psk_default(struct key *keyring,
151151
}
152152
EXPORT_SYMBOL_GPL(nvme_tls_psk_default);
153153

154-
int nvme_keyring_init(void)
154+
static int __init nvme_keyring_init(void)
155155
{
156156
int err;
157157

@@ -171,14 +171,15 @@ int nvme_keyring_init(void)
171171
}
172172
return 0;
173173
}
174-
EXPORT_SYMBOL_GPL(nvme_keyring_init);
175174

176-
void nvme_keyring_exit(void)
175+
static void __exit nvme_keyring_exit(void)
177176
{
178177
unregister_key_type(&nvme_tls_psk_key_type);
179178
key_revoke(nvme_keyring);
180179
key_put(nvme_keyring);
181180
}
182-
EXPORT_SYMBOL_GPL(nvme_keyring_exit);
183181

184182
MODULE_LICENSE("GPL v2");
183+
MODULE_AUTHOR("Hannes Reinecke <hare@suse.de>");
184+
module_init(nvme_keyring_init);
185+
module_exit(nvme_keyring_exit);

drivers/nvme/host/core.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "nvme.h"
2626
#include "fabrics.h"
2727
#include <linux/nvme-auth.h>
28-
#include <linux/nvme-keyring.h>
2928

3029
#define CREATE_TRACE_POINTS
3130
#include "trace.h"
@@ -4737,16 +4736,11 @@ static int __init nvme_core_init(void)
47374736
result = PTR_ERR(nvme_ns_chr_class);
47384737
goto unregister_generic_ns;
47394738
}
4740-
result = nvme_keyring_init();
4741-
if (result)
4742-
goto destroy_ns_chr;
47434739
result = nvme_init_auth();
47444740
if (result)
4745-
goto keyring_exit;
4741+
goto destroy_ns_chr;
47464742
return 0;
47474743

4748-
keyring_exit:
4749-
nvme_keyring_exit();
47504744
destroy_ns_chr:
47514745
class_destroy(nvme_ns_chr_class);
47524746
unregister_generic_ns:
@@ -4770,7 +4764,6 @@ static int __init nvme_core_init(void)
47704764
static void __exit nvme_core_exit(void)
47714765
{
47724766
nvme_exit_auth();
4773-
nvme_keyring_exit();
47744767
class_destroy(nvme_ns_chr_class);
47754768
class_destroy(nvme_subsys_class);
47764769
class_destroy(nvme_class);

include/linux/nvme-keyring.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ key_serial_t nvme_tls_psk_default(struct key *keyring,
1212
const char *hostnqn, const char *subnqn);
1313

1414
key_serial_t nvme_keyring_id(void);
15-
int nvme_keyring_init(void);
16-
void nvme_keyring_exit(void);
1715

1816
#else
1917

@@ -26,11 +24,5 @@ static inline key_serial_t nvme_keyring_id(void)
2624
{
2725
return 0;
2826
}
29-
static inline int nvme_keyring_init(void)
30-
{
31-
return 0;
32-
}
33-
static inline void nvme_keyring_exit(void) {}
34-
3527
#endif /* !CONFIG_NVME_KEYRING */
3628
#endif /* _NVME_KEYRING_H */

0 commit comments

Comments
 (0)