Commit d1478376 authored by Zizhi Wo's avatar Zizhi Wo
Browse files

fs/dirty_pages: add last read check in seq_read_dirty()

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



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

When we call seq_read_dirty() for the last read, m->count is the same value
as m->from, and we need to return 0 instead of an error.

Fixes: 5d93db93 ("fs/dirty_pages: fix some errors in seq_read_dirty()")
Signed-off-by: default avatarZizhi Wo <wozizhi@huawei.com>
parent 8fd5d7da
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -218,6 +218,9 @@ static ssize_t seq_read_dirty(
	}

	n = min(m->count - m->from, size);
	/* check if this is the last read */
	if (n == 0)
		goto done;
	n -= copy_to_user(buf, m->buf + m->from, n);
	if (unlikely(!n)) {
		err = -EFAULT;