Skip to content

Commit cef9f5f

Browse files
Yang Yingliangakpm00
authored andcommitted
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>
1 parent f81259c commit cef9f5f

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

kernel/fail_function.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,13 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
294294
}
295295

296296
ret = register_kprobe(&attr->kp);
297-
if (!ret)
298-
fei_debugfs_add_attr(attr);
299-
if (ret < 0)
297+
if (ret) {
300298
fei_attr_remove(attr);
301-
else {
302-
list_add_tail(&attr->list, &fei_attr_list);
303-
ret = count;
299+
goto out;
304300
}
301+
fei_debugfs_add_attr(attr);
302+
list_add_tail(&attr->list, &fei_attr_list);
303+
ret = count;
305304
out:
306305
mutex_unlock(&fei_lock);
307306
kfree(buf);

0 commit comments

Comments
 (0)