[PATCH] fault-injection: handle EI_ETYPE_TRUE
From: Barnabás Pőcze
Date: Thu Sep 24 2020 - 12:49:13 EST
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@xxxxxxxxxxxxxx>
---
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