Commit 7d709943 authored by Sean Fu's avatar Sean Fu Committed by Thomas Gleixner

x86/sysfs: Fix off-by-one error in loop termination

An off-by-one error in loop terminantion conditions in
create_setup_data_nodes() will lead to memory leak when
create_setup_data_node() failed.
Signed-off-by: default avatarSean Fu <fxinrong@gmail.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1505090001-1157-1-git-send-email-fxinrong@gmail.com
parent a3c4fb7c
...@@ -299,7 +299,7 @@ static int __init create_setup_data_nodes(struct kobject *parent) ...@@ -299,7 +299,7 @@ static int __init create_setup_data_nodes(struct kobject *parent)
return 0; return 0;
out_clean_nodes: out_clean_nodes:
for (j = i - 1; j > 0; j--) for (j = i - 1; j >= 0; j--)
cleanup_setup_data_node(*(kobjp + j)); cleanup_setup_data_node(*(kobjp + j));
kfree(kobjp); kfree(kobjp);
out_setup_data_kobj: out_setup_data_kobj:
......
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