summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonino A. Daplas <adaplas@gmail.com>2006-04-19 17:01:21 +0000
committerGreg Kroah-Hartman <gregkh@suse.de>2006-04-24 09:56:05 -0700
commitfd9b012814bebde59160283a13487841ccdfcce5 (patch)
tree3e54c702f11a275599cece2f73c372b565acea16
parent95fb678bf90572414b1c2f239c6a44226049ba8a (diff)
[PATCH] fbdev: Fix return error of fb_write
Fix return code of fb_write(): If at least 1 byte was transferred to the device, return number of bytes, otherwise: - return -EFBIG - if file offset is past the maximum allowable offset or size is greater than framebuffer length - return -ENOSPC - if size is greater than framebuffer length - offset Signed-off-by: Antonino Daplas <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/video/fbmem.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 996c7b58564e..b3094aeda1ef 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -669,13 +669,19 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
total_size = info->fix.smem_len;
if (p > total_size)
- return 0;
+ return -EFBIG;
- if (count >= total_size)
+ if (count > total_size) {
+ err = -EFBIG;
count = total_size;
+ }
+
+ if (count + p > total_size) {
+ if (!err)
+ err = -ENOSPC;
- if (count + p > total_size)
count = total_size - p;
+ }
buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
GFP_KERNEL);
@@ -717,7 +723,7 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
kfree(buffer);
- return (err) ? err : cnt;
+ return (cnt) ? cnt : err;
}
#ifdef CONFIG_KMOD