]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
linux: allow for NULL argument in nvme_lookup_keyring()
authorHannes Reinecke <hare@suse.de>
Wed, 21 Feb 2024 14:07:28 +0000 (15:07 +0100)
committerDaniel Wagner <wagi@monom.org>
Thu, 7 Mar 2024 13:49:46 +0000 (14:49 +0100)
Use the default '.nvme' keyring when nvme_lookup_keyring() is called
with a NULL argument.

Signed-off-by: Hannes Reinecke <hare@suse.de>
src/nvme/linux.c

index e29d9e7270d44cbcbfd57f75febc8c326ed07ffd..1127fc843d07509c1b6619bb8a7ac269ba92e391 100644 (file)
@@ -31,6 +31,8 @@
 
 #ifdef CONFIG_KEYUTILS
 #include <keyutils.h>
+
+#define NVME_TLS_DEFAULT_KEYRING ".nvme"
 #endif
 
 #include <ccan/endian/endian.h>
@@ -1158,6 +1160,8 @@ long nvme_lookup_keyring(const char *keyring)
 {
        key_serial_t keyring_id;
 
+       if (!keyring)
+               keyring = NVME_TLS_DEFAULT_KEYRING;
        keyring_id = find_key_by_type_and_desc("keyring", keyring, 0);
        if (keyring_id < 0)
                return 0;