Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751224AbdIJPlF (ORCPT ); Sun, 10 Sep 2017 11:41:05 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35973 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750966AbdIJPlE (ORCPT ); Sun, 10 Sep 2017 11:41:04 -0400 X-Google-Smtp-Source: ADKCNb7KQryiHDwwjclyeLv9ylrLsu5gNy3/F/qmMRaSY2CtRNVYd7l7Zy/JyKNQBAXYzPdhM2t4GQ== 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 2/2] x86: Fix off-by-one error in loop termination. Date: Sun, 10 Sep 2017 23:40:48 +0800 Message-Id: <1505058048-23679-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