Skip to contentSkip to conversation

fbmem.c : FBIOGETCMAP

DISCUSSION Jon Smirl 2 participants 4 messages Jan 5, 2003 Framebuffer layer

lore
Share & tools
lore

Jon Smirl

author
#0 lore raw

I'm using 2.53 and I ran into this when running
fbtest. It looks like a return went missing.

	case FBIOGETCMAP:
		if (copy_from_user(&cmap, (void *) arg,
sizeof(cmap)))
			return -EFAULT;
		fb_copy_cmap(&info->cmap, &cmap, 0);
	case FBIOPAN_DISPLAY:

In 2.4 it looked like this:

	case FBIOGETCMAP:
		if (copy_from_user(&cmap, (void *) arg,
sizeof(cmap)))
			return -EFAULT;
		return (fb->fb_get_cmap(&cmap, 0,

PROC_CONSOLE(info), info));
case FBIOPAN_DISPLAY:

=====
Jon Smirl
[email protected]

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#1 lore raw
Quoted 13 lines

I'm using 2.53 and I ran into this when running
fbtest. It looks like a return went missing.

	case FBIOGETCMAP:
		if (copy_from_user(&cmap, (void *) arg,
sizeof(cmap)))
			return -EFAULT;
		fb_copy_cmap(&info->cmap, &cmap, 0);
	case FBIOPAN_DISPLAY:

In 2.4 it looked like this:

Quoted 7 lines
	case FBIOGETCMAP:
		if (copy_from_user(&cmap, (void *) arg,
sizeof(cmap)))
			return -EFAULT;
		return (fb->fb_get_cmap(&cmap, 0,

PROC_CONSOLE(info), info));
case FBIOPAN_DISPLAY:

In the latest code there is a return 0 after fb_copy_cmap. So it is fixed with the latest tree.

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

author
#2 lore raw

It needs a copy_to_user too to work. Probably doesn't need the copy_from_user.

Is the right fix?

	case FBIOGETCMAP:
		fb_copy_cmap(&info->cmap, &cmap, 0);
		if (copy_to_user((void *) arg, &cmap, sizeof(cmap)))
			return -EFAULT;
		return 0;

=====
Jon Smirl
[email protected]

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#3 lore raw
Quoted 11 lines

It needs a copy_to_user too to work. Probably doesn't need the copy_from_user.

Is the right fix?

	case FBIOGETCMAP:
		fb_copy_cmap(&info->cmap, &cmap, 0);
		if (copy_to_user((void *) arg, &cmap, sizeof(cmap)))
			return -EFAULT;
		return 0;

Oops. I see the problem. It should be

  fb_copy_cmap(&info->cmap, &cmap, 2);

This tells it to use copy_to_user. I see a few mistakes here. Fixing...

There are several bugs here. I have to cleanup it up. FOr example in fb_copy_cmap there is test for a EFAULT for any copy_* function. This is just broken. It has been broken for a long time. Will fix. Will you test my patch as soon as it is ready?

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf