error-injection: remove EI_ETYPE_NONE
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Mon, 12 Dec 2022 02:46:44 +0000 (11:46 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 3 Feb 2023 06:50:00 +0000 (22:50 -0800)
Patch series "error-injection: Clarify the requirements of error
injectable functions".

Patches for clarifying the requirement of error injectable functions and
to remove the confusing EI_ETYPE_NONE.

This patch (of 2):

Since the EI_ETYPE_NONE is confusing type, replace it with appropriate
errno.  The EI_ETYPE_NONE has been introduced for a dummy (error) value,
but it can mislead people that they can use ALLOW_ERROR_INJECTION(func,
NONE).  So remove it from the EI_ETYPE and use appropriate errno instead.

[akpm@linux-foundation.org: include/linux/error-injection.h needs errno.h]
Link: https://lkml.kernel.org/r/167081319306.387937.10079195394503045678.stgit@devnote3
Link: https://lkml.kernel.org/r/167081320421.387937.4259807348852421112.stgit@devnote3
Fixes: 663faf9f7bee ("error-injection: Add injectable error types")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Borislav Petkov (AMD) <bp@alien8.de>
Cc: Chris Mason <clm@meta.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Florent Revest <revest@chromium.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/asm-generic/error-injection.h
include/linux/error-injection.h
lib/error-inject.c

index fbca56bd9cbc854e394ed6bc392542d5eb20745e..c0b9d3217ed952079e75c7f3e6d13e3c4fbeabd5 100644 (file)
@@ -4,7 +4,6 @@
 
 #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
 enum {
-       EI_ETYPE_NONE,          /* Dummy value for undefined case */
        EI_ETYPE_NULL,          /* Return NULL if failure */
        EI_ETYPE_ERRNO,         /* Return -ERRNO if failure */
        EI_ETYPE_ERRNO_NULL,    /* Return -ERRNO or NULL if failure */
index 635a95caf29f3254cfdcbc69102fb96a1faf4c51..20e738f4eae8ae614dd9e1ba1c3d08904689763f 100644 (file)
@@ -3,6 +3,7 @@
 #define _LINUX_ERROR_INJECTION_H
 
 #include <linux/compiler.h>
+#include <linux/errno.h>
 #include <asm-generic/error-injection.h>
 
 #ifdef CONFIG_FUNCTION_ERROR_INJECTION
@@ -19,7 +20,7 @@ static inline bool within_error_injection_list(unsigned long addr)
 
 static inline int get_injectable_error_type(unsigned long addr)
 {
-       return EI_ETYPE_NONE;
+       return -EOPNOTSUPP;
 }
 
 #endif
index 1afca1b1cdead000910f822fcbcaddc63d4aa310..32c14770508ecf67230a05feb5f941b4e4d8ca61 100644 (file)
@@ -40,7 +40,7 @@ bool within_error_injection_list(unsigned long addr)
 int get_injectable_error_type(unsigned long addr)
 {
        struct ei_entry *ent;
-       int ei_type = EI_ETYPE_NONE;
+       int ei_type = -EINVAL;
 
        mutex_lock(&ei_mutex);
        list_for_each_entry(ent, &error_injection_list, list) {