linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Michal Hocko <mhocko@suse.cz>
Cc: CAI Qian <caiqian@redhat.com>, linux-mm <linux-mm@kvack.org>,
	Nishanth Aravamudan <nacc@us.ibm.com>
Subject: Re: PATCH: hugetlb: handle NODEMASK_ALLOC failure correctly
Date: Thu, 6 Jan 2011 12:38:58 -0800	[thread overview]
Message-ID: <20110106123858.8a585f77.akpm@linux-foundation.org> (raw)
In-Reply-To: <20110106100439.GA5774@tiehlicka.suse.cz>

On Thu, 6 Jan 2011 11:04:39 +0100
Michal Hocko <mhocko@suse.cz> wrote:

> NODEMASK_ALLOC can use kmalloc if nodemask_t > 256 bytes so it might
> fail with NULL as a result. Let's check the resulting variable and
> fail with -ENOMEM if NODEMASK_ALLOC failed.
> 
> Signed-off-by: Michal Hocko <mhocko@suse.cz>
> ---
>  mm/hugetlb.c |   18 +++++++++++++++---
>  1 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 4c0606c..21f31b2 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1439,14 +1439,19 @@ static ssize_t nr_hugepages_store_common(bool obey_mempolicy,
>  	struct hstate *h;
>  	NODEMASK_ALLOC(nodemask_t, nodes_allowed, GFP_KERNEL | __GFP_NORETRY);
>  
> +	if (!nodes_allowed) {
> +		err = -ENOMEM;
> +		goto out;
> +	}

Looks good to me.  I was going to complain that it adds extra unneeded
instructions in the case where the nodemasks are allocated on the
stack.  But it appears that gcc assumes that stack-based variables
cannot have address zero, so if gcc sees this:

	{
		nodemask_t foo;

		if (!&foo) {
			stuff
		}
	}

if just removes it all for us.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-01-06 20:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1060163918.101411.1293793346203.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
2010-12-31 11:08 ` [RFC] /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_overcommit_hugepages CAI Qian
2011-01-04  9:56   ` Michal Hocko
2011-01-04 10:21     ` CAI Qian
2011-01-04 10:52       ` Michal Hocko
2011-01-05  4:52         ` CAI Qian
2011-01-05  8:43           ` Michal Hocko
2011-01-05  8:54             ` CAI Qian
2011-01-05  9:51               ` Michal Hocko
2011-01-05 15:36             ` CAI Qian
2011-01-05 15:59               ` Michal Hocko
2011-01-05 16:42                 ` CAI Qian
2011-01-05 16:44                   ` Michal Hocko
2011-01-05 17:00                     ` CAI Qian
2011-01-05 20:59             ` Andrew Morton
2011-01-06 10:04               ` PATCH: hugetlb: handle NODEMASK_ALLOC failure correctly Michal Hocko
2011-01-06 20:38                 ` Andrew Morton [this message]
2011-01-06 22:23                   ` Michal Hocko
2011-01-04 17:21       ` [RFC] /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_overcommit_hugepages Eric B Munson

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=20110106123858.8a585f77.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=caiqian@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    --cc=nacc@us.ibm.com \
    /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).