Skip to content

Commit

Permalink
staging: android: logger: Correct write offset reset on error
Browse files Browse the repository at this point in the history
In the situation that a writer fails to copy data from userspace it will reset
the write offset to the value it had before it went to sleep. This discarding
any messages written while aquiring the mutex.

Therefore the reset offset needs to be retrieved after acquiring the mutex.

Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Karlis Ogsts authored and Greg Kroah-Hartman committed Jul 23, 2013
1 parent 644d478 commit 72bb99c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/staging/android/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t ppos)
{
struct logger_log *log = file_get_log(iocb->ki_filp);
size_t orig = log->w_off;
size_t orig;
struct logger_entry header;
struct timespec now;
ssize_t ret = 0;
Expand All @@ -490,6 +490,8 @@ static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,

mutex_lock(&log->mutex);

orig = log->w_off;

/*
* Fix up any readers, pulling them forward to the first readable
* entry after (what will be) the new write offset. We do this now
Expand Down

0 comments on commit 72bb99c

Please sign in to comment.