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

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