[LTP] [PATCH v4] madvise11.c:Check loadable module before rmmod

Wei Gao wegao@suse.com
Mon Mar 13 14:41:33 CET 2023


Following fail msg will popup if we try to rmmod buildin module:
rmmod: ERROR: Module hwpoison_inject is builtin

So need add extra check.

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/syscalls/madvise/madvise11.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/madvise/madvise11.c b/testcases/kernel/syscalls/madvise/madvise11.c
index 7e291d571..7c0bef157 100644
--- a/testcases/kernel/syscalls/madvise/madvise11.c
+++ b/testcases/kernel/syscalls/madvise/madvise11.c
@@ -300,12 +300,12 @@ static int open_unpoison_pfn(void)
 	struct mntent *mnt;
 	FILE *mntf;
 
-	if (!find_in_file("/proc/modules", HW_MODULE))
-		hwpoison_probe = 1;
-
 	/* probe hwpoison only if it isn't already there */
-	if (hwpoison_probe)
+	if (!find_in_file("/proc/modules", HW_MODULE)) {
 		SAFE_CMD(cmd_modprobe, NULL, NULL);
+		if (find_in_file("/proc/modules", HW_MODULE))
+			hwpoison_probe = 1;
+	}
 
 	/* debugfs mount point */
 	mntf = setmntent("/etc/mtab", "r");
-- 
2.35.3



More information about the ltp mailing list