[PATCH OLK-5.10] 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: 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; -- 2.39.2

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/3082 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/Z... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/3082 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/Z...
participants (2)
-
patchwork bot
-
Zizhi Wo