summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeung-Woo Kim <sw0312.kim@samsung.com>2021-04-09 18:44:23 +0900
committerLucas De Marchi <lucas.demarchi@intel.com>2021-04-09 08:12:01 -0700
commit39dd171623744ac390dadf487c5a3ebf0b69f2ca (patch)
tree1817bfe267c2d77ba26445c820e1c38745e1f24e
parent8742be0aa5ed14d28980eb706b08e8bdf650f21c (diff)
downloadkmod-39dd171623744ac390dadf487c5a3ebf0b69f2ca.tar.gz
kmod-39dd171623744ac390dadf487c5a3ebf0b69f2ca.tar.bz2
kmod-39dd171623744ac390dadf487c5a3ebf0b69f2ca.zip
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>
-rw-r--r--libkmod/libkmod-config.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c
index 4fdd40f..e83621b 100644
--- a/libkmod/libkmod-config.c
+++ b/libkmod/libkmod-config.c
@@ -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;
}