diff options
author | Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | 2024-05-02 10:43:16 -0400 |
---|---|---|
committer | Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | 2024-05-02 10:43:16 -0400 |
commit | b7fb4410db9d5403c1c7e19595b1eeff0a4322cc (patch) | |
tree | cca7e06573e94e7bd33b1479fbbaf485518718e4 | |
parent | 2d9f5025ed0ee15cbb708921c3581b983b60da32 (diff) | |
download | librseq-b7fb4410db9d5403c1c7e19595b1eeff0a4322cc.tar.gz |
If the read() in get_cpu_mask_from_sysfs() fails with EINTR, the code is
supposed to retry, but the while loop condition has (bytes_read > 0),
which is false when read() fails with EINTR. The result is that the code
exits the loop, having only read part of the string.
Use (bytes_read != 0) in the while loop condition instead, since the
(bytes_read < 0) case is already handled in the loop.
Original fix in liburcu from Benjamin Marzinski <bmarzins@redhat.com>:
commit 9922f33e2986 ("fix: handle EINTR correctly in get_cpu_mask_from_sysfs")
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I134662fe83613ff914433d3b30a63a0134ffa124
-rw-r--r-- | src/smp.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -157,7 +157,7 @@ int get_cpu_mask_from_sysfs(char *buf, size_t max_bytes, const char *path) total_bytes_read += bytes_read; assert(total_bytes_read <= max_bytes); - } while (max_bytes > total_bytes_read && bytes_read > 0); + } while (max_bytes > total_bytes_read && bytes_read != 0); /* * Make sure the mask read is a null terminated string. |