ANDROID: Incremental fs: fix up attempt to copy structures with READ/WRITE_ONCE

READ/WRITE_ONCE are for atomic data types, not for structures.  Fix this
up by doing a memcpy to make it explicit just how messy this copy is...

This fixes a build error on 5.8-rc1, as things are more strict, odds are
it's also wrong in other kernel versions as well...

Cc: Daniel Mentz <danielmentz@google.com>
Cc: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I7ecd3d05bd94c936dd5e69c63028458786f37a78
Git-commit: 197d678a0e
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
This commit is contained in:
Greg Kroah-Hartman 2020-06-25 14:46:07 +02:00 committed by Sayali Lokhande
parent 9cdeb30ad5
commit e8b542dd52

View file

@ -604,8 +604,11 @@ static ssize_t log_read(struct file *f, char __user *buf, size_t len,
reads_to_collect = min_t(ssize_t, rl_size, reads_to_collect);
while (reads_to_collect > 0) {
struct read_log_state next_state = READ_ONCE(log_state->state);
int reads_collected = incfs_collect_logged_reads(
struct read_log_state next_state;
int reads_collected;
memcpy(&next_state, &log_state->state, sizeof(next_state));
reads_collected = incfs_collect_logged_reads(
mi, &next_state, reads_buf,
min_t(ssize_t, reads_to_collect, reads_per_page));
if (reads_collected <= 0) {
@ -624,7 +627,7 @@ static ssize_t log_read(struct file *f, char __user *buf, size_t len,
goto out;
}
WRITE_ONCE(log_state->state, next_state);
memcpy(&log_state->state, &next_state, sizeof(next_state));
total_reads_collected += reads_collected;
buf += reads_collected * sizeof(*reads_buf);
reads_to_collect -= reads_collected;