linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fault-injection: handle EI_ETYPE_TRUE
@ 2020-09-24 16:48 Barnabás Pőcze
  2020-09-24 17:10 ` Masami Hiramatsu
  2020-10-13  9:31 ` Barnabás Pőcze
  0 siblings, 2 replies; 4+ messages in thread
From: Barnabás Pőcze @ 2020-09-24 16:48 UTC (permalink / raw)
  To: linux-kernel, Akinobu Mita, Naveen N. Rao, Anil S Keshavamurthy,
	Masami Hiramatsu, David S. Miller

Commit af3b854492f351d1ff3b4744a83bf5ff7eed4920
("mm/page_alloc.c: allow error injection")
introduced EI_ETYPE_TRUE, but did not extend
 * lib/error-inject.c:error_type_string(), and
 * kernel/fail_function.c:adjust_error_retval()
to accommodate for this change.

Handle EI_ETYPE_TRUE in both functions appropriately by
 * returning "TRUE" in error_type_string(),
 * adjusting the return value to true (1) in adjust_error_retval().

Furthermore, simplify the logic of handling EI_ETYPE_NULL
in adjust_error_retval().

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
---
 kernel/fail_function.c | 6 +++---
 lib/error-inject.c     | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/fail_function.c b/kernel/fail_function.c
index 63b349168da7..4fdea01c0561 100644
--- a/kernel/fail_function.c
+++ b/kernel/fail_function.c
@@ -37,9 +37,7 @@ static unsigned long adjust_error_retval(unsigned long addr, unsigned long retv)
 {
 	switch (get_injectable_error_type(addr)) {
 	case EI_ETYPE_NULL:
-		if (retv != 0)
-			return 0;
-		break;
+		return 0;
 	case EI_ETYPE_ERRNO:
 		if (retv < (unsigned long)-MAX_ERRNO)
 			return (unsigned long)-EINVAL;
@@ -48,6 +46,8 @@ static unsigned long adjust_error_retval(unsigned long addr, unsigned long retv)
 		if (retv != 0 && retv < (unsigned long)-MAX_ERRNO)
 			return (unsigned long)-EINVAL;
 		break;
+	case EI_ETYPE_TRUE:
+		return 1;
 	}

 	return retv;
diff --git a/lib/error-inject.c b/lib/error-inject.c
index aa63751c916f..c73651b15b76 100644
--- a/lib/error-inject.c
+++ b/lib/error-inject.c
@@ -180,6 +180,8 @@ static const char *error_type_string(int etype)
 		return "ERRNO";
 	case EI_ETYPE_ERRNO_NULL:
 		return "ERRNO_NULL";
+	case EI_ETYPE_TRUE:
+		return "TRUE";
 	default:
 		return "(unknown)";
 	}
--
2.28.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-14 15:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24 16:48 [PATCH] fault-injection: handle EI_ETYPE_TRUE Barnabás Pőcze
2020-09-24 17:10 ` Masami Hiramatsu
2020-10-13  9:31 ` Barnabás Pőcze
2020-10-14 15:15   ` Akinobu Mita

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).