]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod-config: fix a memory leak when kmod_list_append() fails
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 9 Apr 2021 09:44:23 +0000 (18:44 +0900)
committerLucas De Marchi <lucas.demarchi@intel.com>
Fri, 9 Apr 2021 15:12:01 +0000 (08:12 -0700)
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>
libkmod/libkmod-config.c

index 4fdd40f86deaa38aa5a04b83e5d93911785b9bc0..e83621b3415796586e3bbc6a68752b11d27fab88 100644 (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;
        }