[PATCH -next 3/3] fail_function: fix wrong use of fei_attr_remove()

From: Yang Yingliang
Date: Fri Aug 26 2022 - 03:26:23 EST


If register_kprobe() fails, the new attr is not added to the list yet,
so it should call fei_attr_free() intstead.

Fixes: 4b1a29a7f542 ("error-injection: Support fault injection framework")
Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
---
kernel/fail_function.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/fail_function.c b/kernel/fail_function.c
index 893e8f9a9118..a7ccd2930c5f 100644
--- a/kernel/fail_function.c
+++ b/kernel/fail_function.c
@@ -295,7 +295,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,

ret = register_kprobe(&attr->kp);
if (ret) {
- fei_attr_remove(attr);
+ fei_attr_free(attr);
goto out;
}
fei_debugfs_add_attr(attr);
--
2.25.1