summaryrefslogtreecommitdiff
path: root/src/modules-load/modules-load.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2012-12-04 13:57:53 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2012-12-04 14:03:40 +0100
commitc007bb1b4d1366130f69dfbde53124211307a31a (patch)
treec348c6b821bb24d2e5f3843714c3ed6c09a54ace /src/modules-load/modules-load.c
parent5fe25affc01fb003a3a66937458a25640a6075ce (diff)
modules-load: fix memory leak when bailing out
Suggested-by: Mauro Dreissig <mukadr@gmail.com>
Diffstat (limited to 'src/modules-load/modules-load.c')
-rw-r--r--src/modules-load/modules-load.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index e72e382e19..f6279e1975 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -64,7 +64,8 @@ static int add_modules(const char *p) {
}
static int parse_proc_cmdline(void) {
- char *line, *w, *state;
+ char _cleanup_free_ *line = NULL;
+ char *w, *state;
int r;
size_t l;
@@ -78,38 +79,30 @@ static int parse_proc_cmdline(void) {
}
FOREACH_WORD_QUOTED(w, l, line, state) {
- char *word;
+ char _cleanup_free_ *word;
word = strndup(w, l);
- if (!word) {
- r = -ENOMEM;
- goto finish;
- }
+ if (!word)
+ return log_oom();
if (startswith(word, "modules-load=")) {
r = add_modules(word + 13);
if (r < 0)
- goto finish;
+ return r;
} else if (startswith(word, "rd.modules-load=")) {
if (in_initrd()) {
r = add_modules(word + 16);
if (r < 0)
- goto finish;
+ return r;
}
}
-
- free(word);
}
- r = 0;
-
-finish:
- free(line);
- return r;
+ return 0;
}
static int load_module(struct kmod_ctx *ctx, const char *m) {