From 6c7776e34456b420344fee2cf279ae30413058e1 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 23 Jan 2018 14:06:31 +0100 Subject: [PATCH] dracut-install: strdup() kmod_module_get_name() string otherwise it can't be used later on after freeing the context. Should resolve https://bugzilla.redhat.com/show_bug.cgi?id=1536609 --- install/dracut-install.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/install/dracut-install.c b/install/dracut-install.c index 90077226b..4b2ff896d 100644 --- a/install/dracut-install.c +++ b/install/dracut-install.c @@ -1391,7 +1391,6 @@ static int install_modules(int argc, char **argv) struct kmod_module *mod = NULL, *mod_o = NULL; - const char *modname = NULL; const char *abskpath = NULL; char *p; int i; @@ -1445,6 +1444,7 @@ static int install_modules(int argc, char **argv) if (argv[i][0] == '/') { _cleanup_kmod_module_unref_list_ struct kmod_list *modlist = NULL; + _cleanup_free_ const char *modname = NULL; r = kmod_module_new_from_path(ctx, argv[i], &mod_o); if (r < 0) { @@ -1454,7 +1454,7 @@ static int install_modules(int argc, char **argv) continue; } /* Check, if we have to load another module with that name instead */ - modname = kmod_module_get_name(mod_o); + modname = strdup(kmod_module_get_name(mod_o)); if (!modname) { if (!arg_optional) { @@ -1530,6 +1530,7 @@ static int install_modules(int argc, char **argv) for (FTSENT *ftsent = fts_read(fts); ftsent != NULL; ftsent = fts_read(fts)) { _cleanup_kmod_module_unref_list_ struct kmod_list *modlist = NULL; + _cleanup_free_ const char *modname = NULL; if((ftsent->fts_info == FTS_D) && !check_module_path(ftsent->fts_accpath)) { fts_set(fts, ftsent, FTS_SKIP); @@ -1552,7 +1553,7 @@ static int install_modules(int argc, char **argv) } /* Check, if we have to load another module with that name instead */ - modname = kmod_module_get_name(mod_o); + modname = strdup(kmod_module_get_name(mod_o)); if (!modname) { log_error("Failed to get name for module '%s'", ftsent->fts_accpath); @@ -1598,7 +1599,7 @@ static int install_modules(int argc, char **argv) } } else { _cleanup_kmod_module_unref_list_ struct kmod_list *modlist = NULL; - char *modname = argv[i]; + char *modname = argv[i]; if (endswith(modname, ".ko")) { int len = strlen(modname); -- 2.47.3