kmalloc() may fail, if so return -ENOMEM.
Signed-off-by: Kulikov Vasiliy <[email protected]>
---
mm/vmalloc.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index b7e314b..f63684a 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2437,8 +2437,11 @@ static int vmalloc_open(struct inode *inode, struct file *file)
unsigned int *ptr = NULL;
int ret;
- if (NUMA_BUILD)
+ if (NUMA_BUILD) {
ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL);
+ if (ptr == NULL)
+ return -ENOMEM;
+ }
ret = seq_open(file, &vmalloc_op);
if (!ret) {
struct seq_file *m = file->private_data;
--
1.7.0.4
On Wed, Jul 28, 2010 at 7:40 PM, Kulikov Vasiliy <[email protected]> wrote:
> kmalloc() may fail, if so return -ENOMEM.
>
> Signed-off-by: Kulikov Vasiliy <[email protected]>
Acked-by: Pekka Enberg <[email protected]>
> ---
> ?mm/vmalloc.c | ? ?5 ++++-
> ?1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index b7e314b..f63684a 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2437,8 +2437,11 @@ static int vmalloc_open(struct inode *inode, struct file *file)
> ? ? ? ?unsigned int *ptr = NULL;
> ? ? ? ?int ret;
>
> - ? ? ? if (NUMA_BUILD)
> + ? ? ? if (NUMA_BUILD) {
> ? ? ? ? ? ? ? ?ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL);
> + ? ? ? ? ? ? ? if (ptr == NULL)
> + ? ? ? ? ? ? ? ? ? ? ? return -ENOMEM;
> + ? ? ? }
> ? ? ? ?ret = seq_open(file, &vmalloc_op);
> ? ? ? ?if (!ret) {
> ? ? ? ? ? ? ? ?struct seq_file *m = file->private_data;
> --
> 1.7.0.4
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to [email protected]. ?For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
>