summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYauheni Kaliuta <yauheni.kaliuta@redhat.com>2020-11-29 18:47:36 +0200
committerLucas De Marchi <lucas.demarchi@intel.com>2020-12-01 00:44:17 -0800
commitbd96d05256db2ff9a89dbe2e8bb6e26fcb800052 (patch)
tree82e7ab0aea70f8c9298115925b147f52f6043f5c
parent47807c4cfa5ffe1e5da27e3d3056d9b47ba998c5 (diff)
downloadkmod-bd96d05256db2ff9a89dbe2e8bb6e26fcb800052.tar.gz
kmod-bd96d05256db2ff9a89dbe2e8bb6e26fcb800052.tar.bz2
kmod-bd96d05256db2ff9a89dbe2e8bb6e26fcb800052.zip
depmod: output_builtin_alias_bin: free idx on error path
idx is allocated in the beginning but it's not freed if there is a failure after the allocation. Change the error path: return immediately if idx allocation fails and then free it in both success and error path at the end. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
-rw-r--r--tools/depmod.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/tools/depmod.c b/tools/depmod.c
index 875e314..2c03dfe 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2412,10 +2412,8 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
return 0;
idx = index_create();
- if (idx == NULL) {
- ret = -ENOMEM;
- goto fail;
- }
+ if (idx == NULL)
+ return -ENOMEM;
ret = kmod_module_get_builtin(depmod->ctx, &builtin);
if (ret < 0) {
@@ -2458,13 +2456,12 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
if (count)
index_write(idx, out);
-
- index_destroy(idx);
-
fail:
if (builtin)
kmod_module_unref_list(builtin);
+ index_destroy(idx);
+
return ret;
}