Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 963654a9 authored by Jaya Kumar's avatar Jaya Kumar Committed by Linus Torvalds
Browse files

fbdev: hecubafb bugfix



This patch is a bugfix for hecubafb_write which would return an incorrect
error value for the bytecount from framebuffer writes.

Signed-off-by: default avatarJaya Kumar <jayakumar.lkml@gmail.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 555514fa
Loading
Loading
Loading
Loading
+27 −25
Original line number Diff line number Diff line
@@ -270,41 +270,43 @@ static void hecubafb_imageblit(struct fb_info *info,
static ssize_t hecubafb_write(struct fb_info *info, const char __user *buf,
				size_t count, loff_t *ppos)
{
	unsigned long p;
	int err=-EINVAL;
	struct hecubafb_par *par;
	unsigned int xres;
	unsigned int fbmemlength;
	struct hecubafb_par *par = info->par;
	unsigned long p = *ppos;
	void *dst;
	int err = 0;
	unsigned long total_size;

	p = *ppos;
	par = info->par;
	xres = info->var.xres;
	fbmemlength = (xres * info->var.yres)/8;
	if (info->state != FBINFO_STATE_RUNNING)
		return -EPERM;

	if (p > fbmemlength)
		return -ENOSPC;
	total_size = info->fix.smem_len;

	if (p > total_size)
		return -EFBIG;

	if (count > total_size) {
		err = -EFBIG;
		count = total_size;
	}

	err = 0;
	if ((count + p) > fbmemlength) {
		count = fbmemlength - p;
	if (count + p > total_size) {
		if (!err)
			err = -ENOSPC;

		count = total_size - p;
	}

	if (count) {
		char *base_addr;
	dst = (void __force *) (info->screen_base + p);

		base_addr = (char __force *)info->screen_base;
		count -= copy_from_user(base_addr + p, buf, count);
		*ppos += count;
	if (copy_from_user(dst, buf, count))
		err = -EFAULT;
	}

	hecubafb_dpy_update(par);
	if  (!err)
		*ppos += count;

	if (count)
		return count;
	hecubafb_dpy_update(par);

	return err;
	return (err) ? err : count;
}

static struct fb_ops hecubafb_ops = {