]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/6.8.6/tools-iio-replace-seekdir-in-iio_generic_buffer.patch
Linux 6.6.27
[thirdparty/kernel/stable-queue.git] / releases / 6.8.6 / tools-iio-replace-seekdir-in-iio_generic_buffer.patch
1 From f35cb5eb490325ca6fe8bbf474341472dedfbe55 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Mon, 8 Jan 2024 12:32:20 +0200
4 Subject: tools: iio: replace seekdir() in iio_generic_buffer
5
6 From: Petre Rodan <petre.rodan@subdimension.ro>
7
8 [ Upstream commit 4e6500bfa053dc133021f9c144261b77b0ba7dc8 ]
9
10 Replace seekdir() with rewinddir() in order to fix a localized glibc bug.
11
12 One of the glibc patches that stable Gentoo is using causes an improper
13 directory stream positioning bug on 32bit arm. That in turn ends up as a
14 floating point exception in iio_generic_buffer.
15
16 The attached patch provides a fix by using an equivalent function which
17 should not cause trouble for other distros and is easier to reason about
18 in general as it obviously always goes back to to the start.
19
20 https://sourceware.org/bugzilla/show_bug.cgi?id=31212
21
22 Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
23 Link: https://lore.kernel.org/r/20240108103224.3986-1-petre.rodan@subdimension.ro
24 Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
25 Signed-off-by: Sasha Levin <sashal@kernel.org>
26 ---
27 tools/iio/iio_utils.c | 2 +-
28 1 file changed, 1 insertion(+), 1 deletion(-)
29
30 diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
31 index 6a00a6eecaef0..c5c5082cb24e5 100644
32 --- a/tools/iio/iio_utils.c
33 +++ b/tools/iio/iio_utils.c
34 @@ -376,7 +376,7 @@ int build_channel_array(const char *device_dir, int buffer_idx,
35 goto error_close_dir;
36 }
37
38 - seekdir(dp, 0);
39 + rewinddir(dp);
40 while (ent = readdir(dp), ent) {
41 if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
42 "_en") == 0) {
43 --
44 2.43.0
45