Blame SOURCES/0001-stress-sysfs-check-for-zero-sysfs-entries-after-prun.patch

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