[PATCH 1/1] ramfs/nommu: fix bug - kernel crash when (nr != lpages)

From: Bryan Wu
Date: Wed Jan 07 2009 - 11:29:46 EST


From: Graf Yang <graf.yang@xxxxxxxxxx>

Avoiding kernel crash when (nr != lpages), and return -ENOMEM,
let the user space application handle this error.

Signed-off-by: Graf Yang <graf.yang@xxxxxxxxxx>
Signed-off-by: Bryan Wu <cooloney@xxxxxxxxxx>
---
fs/ramfs/file-nommu.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index 76acdbc..9311031 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -283,7 +283,8 @@ unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
if (pages) {
ptr = pages;
for (loop = lpages; loop > 0; loop--)
- put_page(*ptr++);
+ if (*ptr)
+ put_page(*ptr++);
kfree(pages);
}

--
1.5.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/