]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
modules-load: return first error in the loop
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 19 Oct 2018 17:34:12 +0000 (02:34 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 Oct 2018 20:04:01 +0000 (05:04 +0900)
Follow-up for a889e206a7434afe28039a1698e5ecf6a3fb7a9b.
Fixes CID#1396280.

src/modules-load/modules-load.c

index 01d909ff191dfc6504ddd1206de1b1677d59b8e7..68d91be2968c0e93aeeabd8035bcf7b5ca98ff91 100644 (file)
@@ -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;
         }