Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934459AbdIYKKR (ORCPT ); Mon, 25 Sep 2017 06:10:17 -0400 Received: from terminus.zytor.com ([65.50.211.136]:46049 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932804AbdIYKKO (ORCPT ); Mon, 25 Sep 2017 06:10:14 -0400 Date: Mon, 25 Sep 2017 03:08:08 -0700 From: tip-bot for Sean Fu Message-ID: Cc: fxinrong@gmail.com, hpa@zytor.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org Reply-To: fxinrong@gmail.com, hpa@zytor.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org In-Reply-To: <1505090001-1157-1-git-send-email-fxinrong@gmail.com> References: <1505090001-1157-1-git-send-email-fxinrong@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/sysfs: Fix off-by-one error in loop termination Git-Commit-ID: 7d7099433d9eaaa5a989a55f1fa354c16a3ad297 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1190 Lines: 34 Commit-ID: 7d7099433d9eaaa5a989a55f1fa354c16a3ad297 Gitweb: http://git.kernel.org/tip/7d7099433d9eaaa5a989a55f1fa354c16a3ad297 Author: Sean Fu AuthorDate: Mon, 11 Sep 2017 08:33:21 +0800 Committer: Thomas Gleixner CommitDate: Mon, 25 Sep 2017 09:36:16 +0200 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: Sean Fu Signed-off-by: Thomas Gleixner Link: http://lkml.kernel.org/r/1505090001-1157-1-git-send-email-fxinrong@gmail.com --- 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 4b0592c..8c1cc08 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: