|
@@ -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;
|
|
total_size = info->fix.smem_len;
|
|
|
|
|
|
if (p > total_size)
|
|
if (p > total_size)
|
|
- return 0;
|
|
|
|
|
|
+ return -EFBIG;
|
|
|
|
|
|
- if (count >= total_size)
|
|
|
|
|
|
+ if (count > total_size) {
|
|
|
|
+ err = -EFBIG;
|
|
count = total_size;
|
|
count = total_size;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (count + p > total_size) {
|
|
|
|
+ if (!err)
|
|
|
|
+ err = -ENOSPC;
|
|
|
|
|
|
- if (count + p > total_size)
|
|
|
|
count = total_size - p;
|
|
count = total_size - p;
|
|
|
|
+ }
|
|
|
|
|
|
buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
|
|
buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
|
|
GFP_KERNEL);
|
|
GFP_KERNEL);
|
|
@@ -722,7 +728,7 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
|
|
|
|
|
|
kfree(buffer);
|
|
kfree(buffer);
|
|
|
|
|
|
- return (err) ? err : cnt;
|
|
|
|
|
|
+ return (cnt) ? cnt : err;
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef CONFIG_KMOD
|
|
#ifdef CONFIG_KMOD
|