From 960feb3a09e43e4eaab6798a0a6502ced2f06487 Mon Sep 17 00:00:00 2001 From: "Antonino A. Daplas" Date: Tue, 18 Apr 2006 22:22:12 -0700 Subject: [PATCH] --- yaml --- r: 26016 b: refs/heads/master c: 6a2a88668e90cd2459d0493e3e3ff17c3557febc h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/video/fbmem.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 1b9330dbab60..d54d072f4556 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a61bdaad6c696e850d8fa412f1f201cbca51ad30 +refs/heads/master: 6a2a88668e90cd2459d0493e3e3ff17c3557febc diff --git a/trunk/drivers/video/fbmem.c b/trunk/drivers/video/fbmem.c index 8d8eadb64853..372aa1776827 100644 --- a/trunk/drivers/video/fbmem.c +++ b/trunk/drivers/video/fbmem.c @@ -674,13 +674,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); @@ -722,7 +728,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