]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/selftests-gpio-mockup-chardev-check-asprintf-for-err.patch
Linux 4.14.105
[thirdparty/kernel/stable-queue.git] / queue-4.19 / selftests-gpio-mockup-chardev-check-asprintf-for-err.patch
1 From bb7b0b44666c0bd9d92ba745288132f96f62195e Mon Sep 17 00:00:00 2001
2 From: Geert Uytterhoeven <geert+renesas@glider.be>
3 Date: Mon, 14 Jan 2019 14:51:33 +0100
4 Subject: selftests: gpio-mockup-chardev: Check asprintf() for error
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 [ Upstream commit 508cacd7da6659ae7b7bdd0a335f675422277758 ]
10
11 With gcc 7.3.0:
12
13 gpio-mockup-chardev.c: In function ‘get_debugfs’:
14 gpio-mockup-chardev.c:62:3: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
15 asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
16 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17
18 Handle asprintf() failures to fix this.
19
20 Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
21 Signed-off-by: Shuah Khan <shuah@kernel.org>
22 Signed-off-by: Sasha Levin <sashal@kernel.org>
23 ---
24 tools/testing/selftests/gpio/gpio-mockup-chardev.c | 9 ++++++---
25 1 file changed, 6 insertions(+), 3 deletions(-)
26
27 diff --git a/tools/testing/selftests/gpio/gpio-mockup-chardev.c b/tools/testing/selftests/gpio/gpio-mockup-chardev.c
28 index f8d468f54e986..aaa1e9f083c37 100644
29 --- a/tools/testing/selftests/gpio/gpio-mockup-chardev.c
30 +++ b/tools/testing/selftests/gpio/gpio-mockup-chardev.c
31 @@ -37,7 +37,7 @@ static int get_debugfs(char **path)
32 struct libmnt_table *tb;
33 struct libmnt_iter *itr = NULL;
34 struct libmnt_fs *fs;
35 - int found = 0;
36 + int found = 0, ret;
37
38 cxt = mnt_new_context();
39 if (!cxt)
40 @@ -58,8 +58,11 @@ static int get_debugfs(char **path)
41 break;
42 }
43 }
44 - if (found)
45 - asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
46 + if (found) {
47 + ret = asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
48 + if (ret < 0)
49 + err(EXIT_FAILURE, "failed to format string");
50 + }
51
52 mnt_free_iter(itr);
53 mnt_free_context(cxt);
54 --
55 2.19.1
56