initrd: fix crash in the NBFT parser

The shared library handle is not initialized when there are no NBFT
entries.

Fixes: 1cb0635d08 ('initrd: add new NBFT parser')
This commit is contained in:
Beniamino Galvani 2025-04-30 09:23:27 +02:00
parent 39b38e5905
commit d26714481d

View file

@ -398,7 +398,8 @@ nmi_nbft_reader_parse(const char *sysfs_dir, char **hostname)
}
g_dir_close(dir);
dlclose(libnvme_handle);
if (libnvme_handle)
dlclose(libnvme_handle);
g_ptr_array_add(a, NULL); /* trailing NULL-delimiter */
return (NMConnection **) g_ptr_array_free(g_steal_pointer(&a), FALSE);
}