Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752103AbdIKAdf (ORCPT ); Sun, 10 Sep 2017 20:33:35 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35145 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751874AbdIKAde (ORCPT ); Sun, 10 Sep 2017 20:33:34 -0400 X-Google-Smtp-Source: ADKCNb4GjZYqbEKfxgpWhEFu3b2iQF4rNVBr0kgVBejjt1E5t4i3HEqgoPhf/wAZvuH3cPO7xb6K7A== From: Sean Fu To: tglx@linutronix.de Cc: mingo@redhat.com, hpa@zytor.com, x86@kernel.org, fxinrong@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH] x86: Fix off-by-one error in loop termination. Date: Mon, 11 Sep 2017 08:33:21 +0800 Message-Id: <1505090001-1157-1-git-send-email-fxinrong@gmail.com> X-Mailer: git-send-email 2.6.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 702 Lines: 24 An off-by-one error in loop terminantion conditions in create_setup_data_nodes will lead to memory leak when create_setup_data_node return error. Signed-off-by: Sean Fu --- arch/x86/kernel/ksysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c index 4afc67f..cfde6c0 100644 --- a/arch/x86/kernel/ksysfs.c +++ b/arch/x86/kernel/ksysfs.c @@ -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: -- 2.6.2