]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/path: set errno in case of error
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 8 Oct 2023 18:47:53 +0000 (20:47 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 24 Nov 2023 10:06:43 +0000 (11:06 +0100)
Some programs like lscpu expect errno to be set if ul_path_cpuparse
fails.

[kzak@redhat.com: - backport to stable/v2.39]

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/path.c

index 1a8a21c124e6c2de15c44e998d2bc4c6b6a41a1f..258fa048d63fd604e3b409787ed126dd6f6c1c78 100644 (file)
@@ -1046,12 +1046,16 @@ static int ul_path_cpuparse(struct path_cxt *pc, cpu_set_t **set, int maxcpus, i
        if (islist) {
                if (cpulist_parse(buf, *set, setsize, 0)) {
                        cpuset_free(*set);
-                       return -EINVAL;
+                       errno = EINVAL;
+                       rc = -errno;
+                       return rc;
                }
        } else {
                if (cpumask_parse(buf, *set, setsize)) {
                        cpuset_free(*set);
-                       return -EINVAL;
+                       errno = EINVAL;
+                       rc = -errno;
+                       return rc;
                }
        }
        return 0;