mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Johan Wessfeldt <johan.wessfeldt@gmail.com>
Cc: tglx@linutronix.de, mingo@redhat.com, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mcheck: Correction to a missing return value from misc_register
Date: Wed, 2 Mar 2011 16:06:01 -0800	[thread overview]
Message-ID: <20110302160601.a8936c21.akpm@linux-foundation.org> (raw)
In-Reply-To: <1298891944-21364-1-git-send-email-johan.wessfeldt@gmail.com>

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.

  reply	other threads:[~2011-03-03  0:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-28 11:19 Johan Wessfeldt
2011-03-03  0:06 ` Andrew Morton [this message]
2011-03-04 16:44   ` J.P. Lacerda
     [not found]     ` <AANLkTi=8GsqKe91cmdF=g3eRjfSywjkkddGtQsqtOoyy@mail.gmail.com>
2011-03-05  8:32       ` J.P. Lacerda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110302160601.a8936c21.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=johan.wessfeldt@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®