fail_function: fix wrong use of fei_attr_remove()
authorYang Yingliang <yangyingliang@huawei.com>
Fri, 26 Aug 2022 07:33:37 +0000 (15:33 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 Sep 2022 04:55:11 +0000 (21:55 -0700)
If register_kprobe() fails, the new attr is not added to the list yet, so
it should call fei_attr_free() intstead.

Link: https://lkml.kernel.org/r/20220826073337.2085798-3-yangyingliang@huawei.com
Fixes: 4b1a29a7f542 ("error-injection: Support fault injection framework")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/fail_function.c

index 893e8f9a911891e6c65cfd451c01b20dc47a8021..a7ccd2930c5f46169f6f7eda93113f9ac8a1568b 100644 (file)
@@ -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);