linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mcheck: Correction to a missing return value from misc_register
@ 2011-02-28 11:19 Johan Wessfeldt
  2011-03-03  0:06 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Johan Wessfeldt @ 2011-02-28 11:19 UTC (permalink / raw)
  To: tglx; +Cc: mingo, x86, linux-kernel, Johan Wessfeldt

Return value from misc_register was not handled correctly
in mcheck_init_device()

Signed-off-by: Johan Wessfeldt <johan.wessfeldt@gmail.com>
---
 arch/x86/kernel/cpu/mcheck/mce.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index d916183..7274a11 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2140,7 +2140,7 @@ static __init int mcheck_init_device(void)
 	}
 
 	register_hotcpu_notifier(&mce_cpu_notifier);
-	misc_register(&mce_log_device);
+	err = misc_register(&mce_log_device);
 
 	return err;
 }
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mcheck: Correction to a missing return value from misc_register
  2011-02-28 11:19 [PATCH] mcheck: Correction to a missing return value from misc_register Johan Wessfeldt
@ 2011-03-03  0:06 ` Andrew Morton
  2011-03-04 16:44   ` J.P. Lacerda
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2011-03-03  0:06 UTC (permalink / raw)
  To: Johan Wessfeldt; +Cc: tglx, mingo, x86, linux-kernel

On Mon, 28 Feb 2011 12:19:04 +0100
Johan Wessfeldt <johan.wessfeldt@gmail.com> wrote:

> Return value from misc_register was not handled correctly
> in mcheck_init_device()
> 
> Signed-off-by: Johan Wessfeldt <johan.wessfeldt@gmail.com>
> ---
>  arch/x86/kernel/cpu/mcheck/mce.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> index d916183..7274a11 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> @@ -2140,7 +2140,7 @@ static __init int mcheck_init_device(void)
>  	}
>  
>  	register_hotcpu_notifier(&mce_cpu_notifier);
> -	misc_register(&mce_log_device);
> +	err = misc_register(&mce_log_device);
>  
>  	return err;
>  }

It should be fixed, but not that way.  If misc_register() fails here,
mcheck_init_device() should undo all the things which it just did.

And the memory leak which occurs if sysdev_class_register() fails and
the memory and other resource leaks which occur if mce_create_device()
fails should be fixed too.

mcheck_init_device() a rather optimistic function.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mcheck: Correction to a missing return value from misc_register
  2011-03-03  0:06 ` Andrew Morton
@ 2011-03-04 16:44   ` J.P. Lacerda
       [not found]     ` <AANLkTi=8GsqKe91cmdF=g3eRjfSywjkkddGtQsqtOoyy@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: J.P. Lacerda @ 2011-03-04 16:44 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Johan Wessfeldt, tglx, mingo, x86, linux-kernel

Andrew,

Where can a memory leak occur in sysdev_class_register()?
If one does occur, should the fix not be applied to
sysdev_class_register(), as opposed to mcheck_init_device()?

Thanks,

J.P.

On Wed, 2011-03-02 at 16:06 -0800, Andrew Morton wrote:
> On Mon, 28 Feb 2011 12:19:04 +0100
> Johan Wessfeldt <johan.wessfeldt@gmail.com> wrote:
> 
> > Return value from misc_register was not handled correctly
> > in mcheck_init_device()
> > 
> > Signed-off-by: Johan Wessfeldt <johan.wessfeldt@gmail.com>
> > ---
> >  arch/x86/kernel/cpu/mcheck/mce.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> > index d916183..7274a11 100644
> > --- a/arch/x86/kernel/cpu/mcheck/mce.c
> > +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> > @@ -2140,7 +2140,7 @@ static __init int mcheck_init_device(void)
> >  	}
> >  
> >  	register_hotcpu_notifier(&mce_cpu_notifier);
> > -	misc_register(&mce_log_device);
> > +	err = misc_register(&mce_log_device);
> >  
> >  	return err;
> >  }
> 
> It should be fixed, but not that way.  If misc_register() fails here,
> mcheck_init_device() should undo all the things which it just did.
> 
> And the memory leak which occurs if sysdev_class_register() fails and
> the memory and other resource leaks which occur if mce_create_device()
> fails should be fixed too.
> 
> mcheck_init_device() a rather optimistic function.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mcheck: Correction to a missing return value from misc_register
       [not found]     ` <AANLkTi=8GsqKe91cmdF=g3eRjfSywjkkddGtQsqtOoyy@mail.gmail.com>
@ 2011-03-05  8:32       ` J.P. Lacerda
  0 siblings, 0 replies; 4+ messages in thread
From: J.P. Lacerda @ 2011-03-05  8:32 UTC (permalink / raw)
  To: Johan Wessfeldt; +Cc: Andrew Morton, tglx, mingo, x86, linux-kernel

Hey Johan,

Sorry for the delayed reply.
Yes, we should go with yours (which you have already sent).

Kind regards,

J.P.

On Fri, 2011-03-04 at 18:50 +0100, Johan Wessfeldt wrote:
> Hi,
> 
> 
> I made another patch for this (yesterday) but  sent it to
> kernel-janitor list for a quick review. (as I'm new to this).
> 
> 
> JP. Lacerda, I noticed you also made a patch. It's very similar.
> Should I still send my patch in, or we go with yours?
> 
> 
> Regards.
> // Johan W.
> 
> 
> On Fri, Mar 4, 2011 at 5:44 PM, J.P. Lacerda <jpl@codethink.co.uk>
> wrote:
>         Andrew,
>         
>         Where can a memory leak occur in sysdev_class_register()?
>         If one does occur, should the fix not be applied to
>         sysdev_class_register(), as opposed to mcheck_init_device()?
>         
>         Thanks,
>         
>         J.P.
>         
>         
>         On Wed, 2011-03-02 at 16:06 -0800, Andrew Morton wrote:
>         > On Mon, 28 Feb 2011 12:19:04 +0100
>         > Johan Wessfeldt <johan.wessfeldt@gmail.com> wrote:
>         >
>         > > Return value from misc_register was not handled correctly
>         > > in mcheck_init_device()
>         > >
>         > > Signed-off-by: Johan Wessfeldt <johan.wessfeldt@gmail.com>
>         > > ---
>         > >  arch/x86/kernel/cpu/mcheck/mce.c |    2 +-
>         > >  1 files changed, 1 insertions(+), 1 deletions(-)
>         > >
>         > > diff --git a/arch/x86/kernel/cpu/mcheck/mce.c
>         b/arch/x86/kernel/cpu/mcheck/mce.c
>         > > index d916183..7274a11 100644
>         > > --- a/arch/x86/kernel/cpu/mcheck/mce.c
>         > > +++ b/arch/x86/kernel/cpu/mcheck/mce.c
>         > > @@ -2140,7 +2140,7 @@ static __init int
>         mcheck_init_device(void)
>         > >     }
>         > >
>         > >     register_hotcpu_notifier(&mce_cpu_notifier);
>         > > -   misc_register(&mce_log_device);
>         > > +   err = misc_register(&mce_log_device);
>         > >
>         > >     return err;
>         > >  }
>         >
>         > It should be fixed, but not that way.  If misc_register()
>         fails here,
>         > mcheck_init_device() should undo all the things which it
>         just did.
>         >
>         > And the memory leak which occurs if sysdev_class_register()
>         fails and
>         > the memory and other resource leaks which occur if
>         mce_create_device()
>         > fails should be fixed too.
>         >
>         > mcheck_init_device() a rather optimistic function.
>         
>         > --
>         > To unsubscribe from this list: send the line "unsubscribe
>         linux-kernel" in
>         > the body of a message to majordomo@vger.kernel.org
>         > More majordomo info at
>          http://vger.kernel.org/majordomo-info.html
>         > Please read the FAQ at  http://www.tux.org/lkml/
>         
>         
> 
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-03-05  8:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-28 11:19 [PATCH] mcheck: Correction to a missing return value from misc_register Johan Wessfeldt
2011-03-03  0:06 ` Andrew Morton
2011-03-04 16:44   ` J.P. Lacerda
     [not found]     ` <AANLkTi=8GsqKe91cmdF=g3eRjfSywjkkddGtQsqtOoyy@mail.gmail.com>
2011-03-05  8:32       ` J.P. Lacerda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).