Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752017AbdIKAwX (ORCPT ); Sun, 10 Sep 2017 20:52:23 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:37567 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751827AbdIKAwW (ORCPT ); Sun, 10 Sep 2017 20:52:22 -0400 X-Google-Smtp-Source: ADKCNb4vXUuow+xp6J15Lq60dtoBat2xp/k2rTWBmZvlxwoFy/P/wW3w5FJSu7mzXOyuSyLJ7H5zyA== Date: Mon, 11 Sep 2017 08:52:13 +0800 From: Sean Fu To: tglx@linutronix.de Cc: mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86: Fix off-by-one error in loop termination. Message-ID: <20170911005212.GA1254@linux-zmni.DHCP> Mail-Followup-To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org References: <1505090001-1157-1-git-send-email-fxinrong@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1505090001-1157-1-git-send-email-fxinrong@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 941 Lines: 32 On Mon, Sep 11, 2017 at 08:33:21AM +0800, Sean Fu wrote: > 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 > Appologize for the wrong subject prefix in previous email. Resent the patch right now. Could you please review this patch? Thanks