libkmod-config: fix a memory leak when kmod_list_append() fails

From kmod_config_new(), when kmod_list_append() fails,
fix not list-appended kmod_config_path leak.

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
This commit is contained in:
Seung-Woo Kim 2021-04-09 18:44:23 +09:00 committed by Lucas De Marchi
parent 8742be0aa5
commit 39dd171623

View File

@ -909,8 +909,10 @@ int kmod_config_new(struct kmod_ctx *ctx, struct kmod_config **p_config,
memcpy(cf->path, path, pathlen);
tmp = kmod_list_append(path_list, cf);
if (tmp == NULL)
if (tmp == NULL) {
free(cf);
goto oom;
}
path_list = tmp;
}