Skip to content

Commit

Permalink
staging: android: logger: clarify non-update of w_off in do_write_log…
Browse files Browse the repository at this point in the history
…_from_user

Add comment to explain when w_off is not updated in case of failed second
fragment copy to buffer.

Signed-off-by: Tim Bird <tim.bird@am.sony.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Tim Bird authored and Greg Kroah-Hartman committed Feb 9, 2012
1 parent 169c843 commit 350a195
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/staging/android/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ static ssize_t do_write_log_from_user(struct logger_log *log,

if (count != len)
if (copy_from_user(log->buffer, buf + len, count - len))
/*
* Note that by not updating w_off, this abandons the
* portion of the new entry that *was* successfully
* copied, just above. This is intentional to avoid
* message corruption from missing fragments.
*/
return -EFAULT;

log->w_off = logger_offset(log, log->w_off + count);
Expand Down

0 comments on commit 350a195

Please sign in to comment.