summaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/vpe.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2008-03-13 15:16:53 +0000
committerRalf Baechle <ralf@linux-mips.org>2008-04-01 15:46:33 +0100
commit5408c490a4297556cfe10ba9725b1bd13f4a8377 (patch)
tree2db6f1e490e832e3d7b918d5fe79d7260e612d30 /arch/mips/kernel/vpe.c
parenta9edadbf790d72adf6ebed476cb5caf7743e7e4a (diff)
downloadop-kernel-dev-5408c490a4297556cfe10ba9725b1bd13f4a8377.zip
op-kernel-dev-5408c490a4297556cfe10ba9725b1bd13f4a8377.tar.gz
[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>
Diffstat (limited to 'arch/mips/kernel/vpe.c')
-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 eed2dc4..39804c5 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -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++) {
OpenPOWER on IntegriCloud