From: Yu Watanabe Date: Fri, 19 Oct 2018 17:34:12 +0000 (+0900) Subject: modules-load: return first error in the loop X-Git-Tag: v240~486^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=db8794c3a0aa3faa1796dc67d415357a86598172;p=thirdparty%2Fsystemd.git modules-load: return first error in the loop Follow-up for a889e206a7434afe28039a1698e5ecf6a3fb7a9b. Fixes CID#1396280. --- diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index 01d909ff191..68d91be2968 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -81,10 +81,10 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent char *l; int k; - r = read_line(f, LONG_LINE_MAX, &line); - if (r < 0) - return log_error_errno(errno, "Failed to read file '%s': %m", path); - if (r == 0) + k = read_line(f, LONG_LINE_MAX, &line); + if (k < 0) + return log_error_errno(k, "Failed to read file '%s': %m", path); + if (k == 0) break; l = strstrip(line); @@ -94,7 +94,7 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent continue; k = module_load_and_warn(ctx, l, true); - if (k < 0 && r == 0) + if (k < 0 && r >= 0) r = k; }