]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[MIPS] VPE loader: Check result of memory allocation.
authorRalf Baechle <ralf@linux-mips.org>
Thu, 13 Mar 2008 15:16:53 +0000 (15:16 +0000)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 1 Apr 2008 14:46:33 +0000 (15:46 +0100)
And while at it, make it a little cleaner.  Issue originally reported by
Tiejun Chen (tiejun.chen@windriver.com).

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/kernel/vpe.c

index eed2dc4273e08a47af6472533ce9f77dea7b5e2d..39804c584eddbaf794a3eda5526bd8122f3bb817 100644 (file)
@@ -262,13 +262,21 @@ void dump_mtregs(void)
 /* Find some VPE program space  */
 static void *alloc_progmem(unsigned long len)
 {
+       void *addr;
+
 #ifdef CONFIG_MIPS_VPE_LOADER_TOM
-       /* this means you must tell linux to use less memory than you physically have */
-       return pfn_to_kaddr(max_pfn);
+       /*
+        * This means you must tell Linux to use less memory than you
+        * physically have, for example by passing a mem= boot argument.
+        */
+       addr = pfn_to_kaddr(max_pfn);
+       memset(addr, 0, len);
 #else
-       // simple grab some mem for now
-       return kmalloc(len, GFP_KERNEL);
+       /* simple grab some mem for now */
+       addr = kzalloc(len, GFP_KERNEL);
 #endif
+
+       return addr;
 }
 
 static void release_progmem(void *ptr)
@@ -884,9 +892,10 @@ static int vpe_elfload(struct vpe * v)
        }
 
        v->load_addr = alloc_progmem(mod.core_size);
-       memset(v->load_addr, 0, mod.core_size);
+       if (!v->load_addr)
+               return -ENOMEM;
 
-       printk("VPE loader: loading to %p\n", v->load_addr);
+       pr_info("VPE loader: loading to %p\n", v->load_addr);
 
        if (relocate) {
                for (i = 0; i < hdr->e_shnum; i++) {