Enabling CONFIG_CRYPTO_RSA, but not CONFIG_CRYPTO_BUILTIN_KEYS currently
results in a linker error:

  crypto/rsa.c:484: undefined reference to `public_key_add'

Fix this by only calling public_key_add() if we have
CONFIG_CRYPTO_BUILTIN_KEYS=y. If that option is disabled, it means only
standalone keys can be used.

Fixes: 54caa724c737 ("crypto: add public_key functions")
Signed-off-by: Ahmad Fatoum <[email protected]>
---
 crypto/rsa.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/crypto/rsa.c b/crypto/rsa.c
index 04b6c9d8c729..d3a48b6809de 100644
--- a/crypto/rsa.c
+++ b/crypto/rsa.c
@@ -488,11 +488,12 @@ static void rsa_init_keys_of(void)
        }
 }
 
-static int rsa_init_keys(void)
+static __maybe_unused int rsa_init_keys(void)
 {
        rsa_init_keys_of();
 
        return 0;
 }
-
+#ifdef CONFIG_CRYPTO_BUILTIN_KEYS
 device_initcall(rsa_init_keys);
+#endif
-- 
2.39.5


Reply via email to