From db8794c3a0aa3faa1796dc67d415357a86598172 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 20 Oct 2018 02:34:12 +0900 Subject: [PATCH] modules-load: return first error in the loop Follow-up for a889e206a7434afe28039a1698e5ecf6a3fb7a9b. Fixes CID#1396280. --- src/modules-load/modules-load.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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; } -- 2.47.3