Commit cef9f5f8 authored by Yang Yingliang's avatar Yang Yingliang Committed by Andrew Morton

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.comSigned-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent f81259c6
...@@ -294,14 +294,13 @@ static ssize_t fei_write(struct file *file, const char __user *buffer, ...@@ -294,14 +294,13 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
} }
ret = register_kprobe(&attr->kp); ret = register_kprobe(&attr->kp);
if (!ret) if (ret) {
fei_debugfs_add_attr(attr);
if (ret < 0)
fei_attr_remove(attr); fei_attr_remove(attr);
else { goto out;
}
fei_debugfs_add_attr(attr);
list_add_tail(&attr->list, &fei_attr_list); list_add_tail(&attr->list, &fei_attr_list);
ret = count; ret = count;
}
out: out:
mutex_unlock(&fei_lock); mutex_unlock(&fei_lock);
kfree(buf); kfree(buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment