|
|
03988b |
From 6a22f648bd3452c83c5f88ec530d496fefe5e9a0 Mon Sep 17 00:00:00 2001
|
|
|
03988b |
From: Colin Ian King <colin.i.king@gmail.com>
|
|
|
03988b |
Date: Mon, 21 Nov 2022 12:16:47 +0000
|
|
|
03988b |
Subject: [PATCH 1/3] stress-sysfs: check for zero sysfs entries after pruning
|
|
|
03988b |
the directory
|
|
|
03988b |
|
|
|
03988b |
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
|
|
|
03988b |
---
|
|
|
03988b |
stress-sysfs.c | 18 +++++++++++-------
|
|
|
03988b |
1 file changed, 11 insertions(+), 7 deletions(-)
|
|
|
03988b |
|
|
|
03988b |
diff --git a/stress-sysfs.c b/stress-sysfs.c
|
|
|
03988b |
index 00fe9ba08100..24267d00ee5a 100644
|
|
|
03988b |
--- a/stress-sysfs.c
|
|
|
03988b |
+++ b/stress-sysfs.c
|
|
|
03988b |
@@ -634,14 +634,11 @@ static int stress_sysfs(const stress_args_t *args)
|
|
|
03988b |
}
|
|
|
03988b |
|
|
|
03988b |
n = scandir("/sys", &dlist, NULL, alphasort);
|
|
|
03988b |
- if (n <= 0) {
|
|
|
03988b |
- if (args->instance == 0)
|
|
|
03988b |
- pr_inf_skip("%s: no /sys entries found, skipping stressor\n", args->name);
|
|
|
03988b |
- stress_dirent_list_free(dlist, n);
|
|
|
03988b |
- (void)munmap((void *)ctxt, sizeof(*ctxt));
|
|
|
03988b |
- return EXIT_NO_RESOURCE;
|
|
|
03988b |
- }
|
|
|
03988b |
+ if (n <= 0)
|
|
|
03988b |
+ goto exit_no_sysfs_entries;
|
|
|
03988b |
n = stress_dirent_list_prune(dlist, n);
|
|
|
03988b |
+ if (n <= 0)
|
|
|
03988b |
+ goto exit_no_sysfs_entries;
|
|
|
03988b |
|
|
|
03988b |
os_release = 0;
|
|
|
03988b |
#if defined(HAVE_UNAME) && \
|
|
|
03988b |
@@ -806,10 +803,17 @@ finish:
|
|
|
03988b |
(void)close(ctxt->kmsgfd);
|
|
|
03988b |
(void)shim_pthread_spin_destroy(&lock);
|
|
|
03988b |
|
|
|
03988b |
+exit_free:
|
|
|
03988b |
stress_dirent_list_free(dlist, n);
|
|
|
03988b |
(void)munmap((void *)ctxt, sizeof(*ctxt));
|
|
|
03988b |
|
|
|
03988b |
return rc;
|
|
|
03988b |
+
|
|
|
03988b |
+exit_no_sysfs_entries:
|
|
|
03988b |
+ if (args->instance == 0)
|
|
|
03988b |
+ pr_inf_skip("%s: no /sys entries found, skipping stressor\n", args->name);
|
|
|
03988b |
+ rc = EXIT_NO_RESOURCE;
|
|
|
03988b |
+ goto exit_free;
|
|
|
03988b |
}
|
|
|
03988b |
|
|
|
03988b |
stressor_info_t stress_sysfs_info = {
|
|
|
03988b |
--
|
|
|
03988b |
2.38.1
|
|
|
03988b |
|