linux-alpha.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: rth@twiddle.net, linux-alpha@vger.kernel.org
Subject: Re: [PATCH] alpha: kmalloc failure ignored in process_reloc_for_got()
Date: Wed, 9 Sep 2009 15:18:48 -0700	[thread overview]
Message-ID: <20090909151848.45db437f.akpm@linux-foundation.org> (raw)
In-Reply-To: <4AA6EB5A.5090309@gmail.com>

On Wed, 09 Sep 2009 01:40:10 +0200
Roel Kluin <roel.kluin@gmail.com> wrote:

> Prevent NULL dereference if kmalloc() fails.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> Found with sed: http://kernelnewbies.org/roelkluin
> 
> diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
> index ebc3c89..8ceec20 100644
> --- a/arch/alpha/kernel/module.c
> +++ b/arch/alpha/kernel/module.c
> @@ -73,6 +73,8 @@ process_reloc_for_got(Elf64_Rela *rela,
>  		}
>  
>  	g = kmalloc (sizeof (*g), GFP_KERNEL);
> +	if (g == NULL)
> +		return;
>  	g->next = chains[r_sym].next;
>  	g->r_addend = r_addend;
>  	g->got_offset = *poffset;

I don't know if that's an improvement.  afacit the kernel will now
blunder along and do something wrong.  An oops might well be
preferable behaviour.

IOW, we should handle this failure properly - back out, clean
everything up, return -ENOMEM to userspace


  reply	other threads:[~2009-09-09 22:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-08 23:40 [PATCH] alpha: kmalloc failure ignored in process_reloc_for_got() Roel Kluin
2009-09-09 22:18 ` Andrew Morton [this message]
2009-09-18 21:14   ` Roel Kluin

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=20090909151848.45db437f.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-alpha@vger.kernel.org \
    --cc=roel.kluin@gmail.com \
    --cc=rth@twiddle.net \
    /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;
as well as URLs for NNTP newsgroup(s).