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

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