Commit 40a88773 authored by Zizhi Wo's avatar Zizhi Wo Committed by openeuler-sync-bot
Browse files

fs/dirty_pages: fix some errors in seq_read_dirty()

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8JUUC?from=project-issue



--------------------------------

In seq_read_dirty(), the parameter passed into simple_read_from_buffer()
will cause problem on a 32-bit system; The simple_read_from_buffer()
function has a lot of redundancy checks inside. Replaced it with
copy_to_user() and add the return value check. And the update of the
"copied" character count in seq_read_dirty() is also incorrect, fixed it.

Fixes: aeb96447 ("fs/dirty_pages: dump the number of dirty pages for each inode")
Signed-off-by: default avatarZizhi Wo <wozizhi@huawei.com>
(cherry picked from commit 5a1ee702)
parent d0d949e1
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -217,12 +217,12 @@ static ssize_t seq_read_dirty(
	}

	n = min(m->count - m->from, size);
	err = simple_read_from_buffer(buf, n,
		(loff_t *) &m->from, m->buf, m->count);
	if (err < 0) {
	n -= copy_to_user(buf, m->buf + m->from, n);
	if (unlikely(!n)) {
		err = -EFAULT;
		goto done;
	}
	m->from += n;
	copied += n;
done:
	if (!copied)