Commit b5013893 authored by Zheng Yejian's avatar Zheng Yejian Committed by Zheng Zengkai
Browse files

livepatch/core: Fix livepatch/state leak on error path

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5WF0G


CVE: NA

--------------------------------

File '/proc/livepatch/state' should be removed before removing
'/proc/livepatch', otherwise following log will appear:
  remove_proc_entry: removing non-empty directory '/proc/livepatch',
  leaking at least 'state'

Fixes: c33e4283 ("livepatch/core: Allow implementation without ftrace")
Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
Reviewed-by: default avatarKuohai Xu <xukuohai@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 8c4631a7
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2331,13 +2331,15 @@ static int __init klp_init(void)

	klp_root_kobj = kobject_create_and_add("livepatch", kernel_kobj);
	if (!klp_root_kobj)
		goto error_remove;
		goto error_remove_state;

#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
	arch_klp_init();
#endif
	return 0;

error_remove_state:
	remove_proc_entry("livepatch/state", NULL);
error_remove:
	remove_proc_entry("livepatch", NULL);
error_out: