mirror of
https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
synced 2024-11-26 21:33:42 +08:00
libkmod: Clean up all dependencies on error path
If kmod_module_parse_depline runs out of memory, it is possible that not all dependency modules are unlinked. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/211 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
This commit is contained in:
parent
6ac1bccfe1
commit
d090fb3ae5
@ -146,6 +146,7 @@ void kmod_module_parse_depline(struct kmod_module *mod, char *line)
|
||||
p++;
|
||||
for (p = strtok_r(p, " \t", &saveptr); p != NULL;
|
||||
p = strtok_r(NULL, " \t", &saveptr)) {
|
||||
struct kmod_list *l_new;
|
||||
struct kmod_module *depmod = NULL;
|
||||
const char *path;
|
||||
int err;
|
||||
@ -164,7 +165,12 @@ void kmod_module_parse_depline(struct kmod_module *mod, char *line)
|
||||
|
||||
DBG(ctx, "add dep: %s\n", path);
|
||||
|
||||
list = kmod_list_prepend(list, depmod);
|
||||
l_new = kmod_list_prepend(list, depmod);
|
||||
if (l_new == NULL) {
|
||||
ERR(ctx, "could not add dependency for %s\n", mod->name);
|
||||
goto fail;
|
||||
}
|
||||
list = l_new;
|
||||
}
|
||||
|
||||
DBG(ctx, "%zu dependencies for %s\n", n, mod->name);
|
||||
|
Loading…
Reference in New Issue
Block a user