Skip to contentSkip to conversation

mm: check kmalloc() return value

PATCH Applied Kulikov Vasiliy 2 participants 2 messages Jul 28, 2010

Subsystems (3)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 5/10 mm: check kmalloc() return value

kmalloc() may fail, if so return -ENOMEM.

---
 mm/vmalloc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
mm/vmalloc.c +4 -1
index b7e314b..f63684a 100644
@@ -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;
Signature · 1 line
1.7.0.4
Acked-by on v1 5/10
#1 lore raw
Quoted 3 lines · Kulikov Vasiliy

kmalloc() may fail, if so return -ENOMEM.

Quoted 24 lines

---
 mm/vmalloc.c |    5 ++++-

 1 files changed, 4 insertions(+), 1 deletions(-)
mm/vmalloc.c +4 -2
index b7e314b..f63684a 100644
@@ -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

Quoted 6 lines

--
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>

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html