lkml.org 
[lkml]   [2017]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] x86: Fix off-by-one error in loop termination.
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 <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 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

\
 
 \ /
  Last update: 2017-09-11 02:52    [W:0.036 / U:4.940 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site