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: 5d93db93b9e7 ("fs/dirty_pages: fix some errors in seq_read_dirty()") Signed-off-by: Zizhi Wo wozizhi@huawei.com --- fs/dirty_pages.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/fs/dirty_pages.c b/fs/dirty_pages.c index b0cf442c5730..f75a5158d94b 100644 --- a/fs/dirty_pages.c +++ b/fs/dirty_pages.c @@ -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;