Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: android: logger: Correct write offset reset on error

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>

authored by

Karlis Ogsts and committed by
Greg Kroah-Hartman
72bb99cf 644d4787

+3 -1
+3 -1
drivers/staging/android/logger.c
··· 469 469 unsigned long nr_segs, loff_t ppos) 470 470 { 471 471 struct logger_log *log = file_get_log(iocb->ki_filp); 472 - size_t orig = log->w_off; 472 + size_t orig; 473 473 struct logger_entry header; 474 474 struct timespec now; 475 475 ssize_t ret = 0; ··· 489 489 return 0; 490 490 491 491 mutex_lock(&log->mutex); 492 + 493 + orig = log->w_off; 492 494 493 495 /* 494 496 * Fix up any readers, pulling them forward to the first readable