diff options
author | Yang Yingliang <yangyingliang@huawei.com> | 2022-08-26 15:33:36 +0800 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2022-09-11 21:55:11 -0700 |
commit | cef9f5f866ad45a2dd64fed6e6b657043c2c6f17 (patch) | |
tree | a99255bc2ae6e0f591b0bd4dd7e75025859a91f7 | |
parent | f81259c6dbcefb255fa473090cd975f3827bca89 (diff) | |
download | lwn-cef9f5f866ad45a2dd64fed6e6b657043c2c6f17.tar.gz lwn-cef9f5f866ad45a2dd64fed6e6b657043c2c6f17.zip |
fail_function: refactor code of checking return value of register_kprobe()
Refactor the error handling of register_kprobe() to improve readability.
No functional change.
Link: https://lkml.kernel.org/r/20220826073337.2085798-2-yangyingliang@huawei.com
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>
-rw-r--r-- | kernel/fail_function.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/kernel/fail_function.c b/kernel/fail_function.c index 03643e33e4c3..893e8f9a9118 100644 --- a/kernel/fail_function.c +++ b/kernel/fail_function.c @@ -294,14 +294,13 @@ static ssize_t fei_write(struct file *file, const char __user *buffer, } ret = register_kprobe(&attr->kp); - if (!ret) - fei_debugfs_add_attr(attr); - if (ret < 0) + if (ret) { fei_attr_remove(attr); - else { - list_add_tail(&attr->list, &fei_attr_list); - ret = count; + goto out; } + fei_debugfs_add_attr(attr); + list_add_tail(&attr->list, &fei_attr_list); + ret = count; out: mutex_unlock(&fei_lock); kfree(buf); |