x86/sysfs: Fix off-by-one error in loop termination
authorSean Fu <fxinrong@gmail.com>
Mon, 11 Sep 2017 00:33:21 +0000 (08:33 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 25 Sep 2017 07:36:16 +0000 (09:36 +0200)
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: Sean Fu <fxinrong@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1505090001-1157-1-git-send-email-fxinrong@gmail.com
arch/x86/kernel/ksysfs.c

index 4b0592c..8c1cc08 100644 (file)
@@ -299,7 +299,7 @@ static int __init create_setup_data_nodes(struct kobject *parent)
        return 0;
 
 out_clean_nodes:
-       for (j = i - 1; j > 0; j--)
+       for (j = i - 1; j >= 0; j--)
                cleanup_setup_data_node(*(kobjp + j));
        kfree(kobjp);
 out_setup_data_kobj: