From: "H. Peter Anvin" <hpa@zytor.com>
To: Veli-Pekka Peltola <veli-pekka.peltola@bluegiga.com>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org,
Russell King <linux@arm.linux.org.uk>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
x86@kernel.org
Subject: Re: [PATCH] mm: module_alloc: check if size is 0
Date: Thu, 01 Mar 2012 12:46:57 -0800 [thread overview]
Message-ID: <4F4FE041.1000507@zytor.com> (raw)
In-Reply-To: <1330631119-10059-1-git-send-email-veli-pekka.peltola@bluegiga.com>
On 03/01/2012 11:45 AM, Veli-Pekka Peltola wrote:
> diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
> index 1e9be5d..d44d212 100644
> --- a/arch/arm/kernel/module.c
> +++ b/arch/arm/kernel/module.c
> @@ -39,8 +39,8 @@
> #ifdef CONFIG_MMU
> void *module_alloc(unsigned long size)
> {
> - return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
> - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
> + return size == 0 ? NULL : __vmalloc_node_range(size, 1, MODULES_VADDR,
> + MODULES_END, GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
> __builtin_return_address(0));
> }
> #endif
> diff --git a/arch/mips/kernel/module.c b/arch/mips/kernel/module.c
> index a5066b1..cd768e9 100644
> --- a/arch/mips/kernel/module.c
> +++ b/arch/mips/kernel/module.c
> @@ -47,8 +47,8 @@ static DEFINE_SPINLOCK(dbe_lock);
> #ifdef MODULE_START
> void *module_alloc(unsigned long size)
> {
> - return __vmalloc_node_range(size, 1, MODULE_START, MODULE_END,
> - GFP_KERNEL, PAGE_KERNEL, -1,
> + return size == 0 ? NULL : __vmalloc_node_range(size, 1, MODULE_START,
> + MODULE_END, GFP_KERNEL, PAGE_KERNEL, -1,
> __builtin_return_address(0));
> }
> #endif
> diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
> index 925179f..bff6118 100644
> --- a/arch/x86/kernel/module.c
> +++ b/arch/x86/kernel/module.c
> @@ -38,7 +38,7 @@
>
> void *module_alloc(unsigned long size)
> {
> - if (PAGE_ALIGN(size) > MODULES_LEN)
> + if (size == 0 || PAGE_ALIGN(size) > MODULES_LEN)
> return NULL;
> return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
> GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
Looks good stylistically but really awkward technically.
I would like to suggest using the idiom:
if (!size)
return NULL;
... consistently; combined with the PAGE_ALIGN() clause for x86 is fine too.
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
next prev parent reply other threads:[~2012-03-01 20:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-01 19:45 [PATCH] mm: module_alloc: check if size is 0 Veli-Pekka Peltola
2012-03-01 20:46 ` H. Peter Anvin [this message]
2012-03-07 13:09 ` [PATCH v2] " Veli-Pekka Peltola
2012-03-19 15:36 ` Veli-Pekka Peltola
2013-06-27 9:39 ` Ralf Baechle
2013-06-27 22:23 ` Andrew Morton
2013-06-27 22:46 ` Joe Perches
2013-07-01 3:18 ` Rusty Russell
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=4F4FE041.1000507@zytor.com \
--to=hpa@zytor.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux@arm.linux.org.uk \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=veli-pekka.peltola@bluegiga.com \
--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