[PATCH] fault-inject: define FAULT_ATTR_INITIALIZER when CONFIG_FAULT_INJECTION is disabled

From: Mallesh Koujalagi

Date: Fri May 15 2026 - 08:16:50 EST


Make FAULT_ATTR_INITIALIZER available without CONFIG_FAULT_INJECTION.
FAULT_ATTR_INITIALIZER is needed for struct initialization but is only
defined when CONFIG_FAULT_INJECTION=y. This breaks code that uses it in
compound literals where DECLARE_FAULT_ATTR cannot be used. Make the
macro available regardless of config to fix build issues.

Signed-off-by: Mallesh Koujalagi <mallesh.koujalagi@xxxxxxxxx>
---
include/linux/fault-inject.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/linux/fault-inject.h b/include/linux/fault-inject.h
index 58fd14c82270..5a572c6db852 100644
--- a/include/linux/fault-inject.h
+++ b/include/linux/fault-inject.h
@@ -60,6 +60,7 @@ bool should_fail(struct fault_attr *attr, ssize_t size);
struct fault_attr {
};

+#define FAULT_ATTR_INITIALIZER {}
#define DECLARE_FAULT_ATTR(name) struct fault_attr name = {}

static inline int setup_fault_attr(struct fault_attr *attr, char *str)
--
2.34.1