On Mon, 28 Apr 2008, Jeff Dike wrote: > On Sat, Apr 26, 2008 at 04:31:32PM +0800, WANG Cong wrote: >> > + rem = copy_to_user(buf, &data->contents[off], count); >> > + *ppos += count - rem; >> > + if (rem > 0) >> > + return -EFAULT; >> >> Could you please explain why check 'rem' after using it here? > > Actually, this isn't as wrong as it looks. copy_to_user returns what > hasn't been copied (rem == remaining). So, I think the mistake is to > return -EFAULT here. Returning the short count would be right, unless > rem == count, in which case we return -EFAULT.
Yes, thanks. -- Hi, I'm a .signature virus, please copy/paste me to help me spread all over the world. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel