summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Marek <mmarek@suse.cz>2013-01-16 17:51:57 +0100
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2013-01-17 23:48:43 -0200
commit6333934e27934a4d8d7dde729e965fab7f2c416b (patch)
tree025a9680c63027c68928bd8909bd7e59f65cff00
parente6b0e49b4ea7937a98b16f23d621244ee1a3e588 (diff)
downloadkmod-6333934e27934a4d8d7dde729e965fab7f2c416b.tar.gz
libkmod-module: Do not free the list in kmod_module_info_append
In error case, just return NULL and let the caller free the list.
-rw-r--r--libkmod/libkmod-module.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 176a5a8..2f4acd5 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -2100,16 +2100,13 @@ static struct kmod_list *kmod_module_info_append(struct kmod_list **list, const
struct kmod_list *n;
info = kmod_module_info_new(key, keylen, value, valuelen);
- if (info == NULL) {
- kmod_module_info_free_list(*list);
+ if (info == NULL)
return NULL;
- }
n = kmod_list_append(*list, info);
- if (n == NULL) {
+ if (n != NULL)
+ *list = n;
+ else
kmod_module_info_free(info);
- kmod_module_info_free_list(*list);
- }
- *list = n;
return n;
}
@@ -2171,6 +2168,10 @@ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, struct kmod_
ret = count;
list_error:
+ if (ret < 0) {
+ kmod_module_info_free_list(*list);
+ *list = NULL;
+ }
free(strings);
return ret;
}