On Tue, Feb 19, 2008 at 05:04:36AM +0100, Arnd Bergmann wrote: > + char buf[3]; > + u32 *val = file->private_data; > + > + if (*val) > + buf[0] = 'Y'; > + else > + buf[0] = 'N'; > + buf[1] = '\n'; > + buf[2] = 0x00; > + return simple_read_from_buffer(user_buf, count, ppos, buf, 2); Ewww - caps, \n... BTW, \0 is pointless here - simple_read_from_buffer() will not access it with these arguments)... > +{ > + char buf[32]; > + int buf_size; > + u32 *val = file->private_data; > + > + buf_size = min(count, (sizeof(buf)-1)); > + if (copy_from_user(buf, user_buf, buf_size)) > + return -EFAULT; > + > + switch (buf[0]) { > + case 'y': > + case 'Y': > + case '1': > + *val = 1; > + break; > + case 'n': > + case 'N': > + case '0': > + *val = 0; > + break; Please, check the length; sloppy input grammar is a bad idea. Hell, at the very least you want -EINVAL if input is not recognized... - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html