Skip to content

Commit

Permalink
fail_function: refactor code of checking return value of register_kpr…
Browse files Browse the repository at this point in the history
…obe()

Refactor the error handling of register_kprobe() to improve readability. 
No functional change.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Yang Yingliang <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Yang Yingliang authored and akpm00 committed Sep 12, 2022
1 parent f81259c commit cef9f5f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions kernel/fail_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cef9f5f

Please sign in to comment.