From: yu kuai yukuai3@huawei.com
euler inclusion category: bugfix bugzilla: 46858 CVE: NA
--------------------------- Just code optimization to make the code better, no functional change.
Signed-off-by: yu kuai yukuai3@huawei.com Reviewed-by: zhangyi (F) yi.zhang@huawei.com Signed-off-by: zhangyi (F) yi.zhang@huawei.com Signed-off-by: Dianfang Zhang zhangdianfang@huawei.com --- fs/dirty_pages.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/fs/dirty_pages.c b/fs/dirty_pages.c index 32bff2d0981a..e8666594142b 100644 --- a/fs/dirty_pages.c +++ b/fs/dirty_pages.c @@ -303,6 +303,11 @@ static int proc_dpages_open(struct inode *inode, struct file *filp) int ret; struct seq_file *m;
+ if (buf_dirty == NULL || buf_size == 0) { + pr_warn("please allocate buffer before getting dirty pages\n"); + return -ENOMEM; + } + ret = single_open(filp, proc_dpages_show, NULL); m = filp->private_data; mutex_lock(&buff_lock); @@ -311,17 +316,11 @@ static int proc_dpages_open(struct inode *inode, struct file *filp) goto out; } if (!ret) { - if (buf_dirty == NULL || buf_size == 0) { - pr_info("please allocate buffer before getting dirty pages\n"); - ret = -ENOMEM; - goto out; - } else { - warn_once = false; - memset(buf_dirty, 0, buf_size); - if (!m->buf) { - m->size = buf_size; - m->buf = buf_dirty; - } + warn_once = false; + memset(buf_dirty, 0, buf_size); + if (!m->buf) { + m->size = buf_size; + m->buf = buf_dirty; } } out: