]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
chcpu: check ul_path_readf_s32() return value [coverity: CID 504056]
authorKarel Zak <kzak@redhat.com>
Mon, 13 Jul 2026 10:32:59 +0000 (12:32 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Jul 2026 10:32:59 +0000 (12:32 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/chcpu.c

index 43d1f457e0a7b116d2143d83361c83218ef4042d..a1d8b347d28b5006b08756cd7f287aa7ead1c2d6 100644 (file)
@@ -103,8 +103,9 @@ static int cpu_enable(struct chcpu_context *ctx, int enable)
                        continue;
                }
 
-               if (ul_path_accessf(ctx->sys, F_OK, "cpu%d/configure", cpu) == 0)
-                       ul_path_readf_s32(ctx->sys, &configured, "cpu%d/configure", cpu);
+               if (ul_path_accessf(ctx->sys, F_OK, "cpu%d/configure", cpu) != 0
+                   || ul_path_readf_s32(ctx->sys, &configured, "cpu%d/configure", cpu) != 0)
+                       configured = -1;
                if (enable) {
                        rc = ul_path_writef_string(ctx->sys, "1", "cpu%d/online", cpu);
                        if (rc != 0 && configured == 0) {