aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2008-03-13 11:16:53 -0400
committerRalf Baechle <ralf@linux-mips.org>2008-04-01 10:46:33 -0400
commit5408c490a4297556cfe10ba9725b1bd13f4a8377 (patch)
tree2db6f1e490e832e3d7b918d5fe79d7260e612d30
parenta9edadbf790d72adf6ebed476cb5caf7743e7e4a (diff)
[MIPS] VPE loader: Check result of memory allocation.
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>
-rw-r--r--arch/mips/kernel/vpe.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index eed2dc4273e0..39804c584edd 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -262,13 +262,21 @@ void dump_mtregs(void)
262/* Find some VPE program space */ 262/* Find some VPE program space */
263static void *alloc_progmem(unsigned long len) 263static void *alloc_progmem(unsigned long len)
264{ 264{
265 void *addr;
266
265#ifdef CONFIG_MIPS_VPE_LOADER_TOM 267#ifdef CONFIG_MIPS_VPE_LOADER_TOM
266 /* this means you must tell linux to use less memory than you physically have */ 268 /*
267 return pfn_to_kaddr(max_pfn); 269 * This means you must tell Linux to use less memory than you
270 * physically have, for example by passing a mem= boot argument.
271 */
272 addr = pfn_to_kaddr(max_pfn);
273 memset(addr, 0, len);
268#else 274#else
269 // simple grab some mem for now 275 /* simple grab some mem for now */
270 return kmalloc(len, GFP_KERNEL); 276 addr = kzalloc(len, GFP_KERNEL);
271#endif 277#endif
278
279 return addr;
272} 280}
273 281
274static void release_progmem(void *ptr) 282static void release_progmem(void *ptr)
@@ -884,9 +892,10 @@ static int vpe_elfload(struct vpe * v)
884 } 892 }
885 893
886 v->load_addr = alloc_progmem(mod.core_size); 894 v->load_addr = alloc_progmem(mod.core_size);
887 memset(v->load_addr, 0, mod.core_size); 895 if (!v->load_addr)
896 return -ENOMEM;
888 897
889 printk("VPE loader: loading to %p\n", v->load_addr); 898 pr_info("VPE loader: loading to %p\n", v->load_addr);
890 899
891 if (relocate) { 900 if (relocate) {
892 for (i = 0; i < hdr->e_shnum; i++) { 901 for (i = 0; i < hdr->e_shnum; i++) {