From 23d54837e4f3a44ad4514d5eae8245c2250217ff Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Thu, 9 Oct 2014 15:25:30 -0700 Subject: [PATCH] fs/proc/task_mmu.c: cleanup the "tail_vma" horror in m_next() 1. Kill the first "vma != NULL" check. Firstly this is not possible, m_next() won't be called if ->start() or the previous ->next() returns NULL. And if it was possible the 2nd "vma != tail_vma" check is buggy, we should not wrongly return ->tail_vma. 2. Make this function readable. The logic is very simple, we should return check "vma != tail" once and return "vm_next || tail_vma". Signed-off-by: Oleg Nesterov Acked-by: Kirill A. Shutemov Acked-by: Cyrill Gorcunov Cc: "Eric W. Biederman" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/proc/task_mmu.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index fdbed8370db6..b7e31836a005 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -210,15 +210,13 @@ out: static void *m_next(struct seq_file *m, void *v, loff_t *pos) { struct proc_maps_private *priv = m->private; - struct vm_area_struct *vma = v; struct vm_area_struct *tail_vma = priv->tail_vma; - struct vm_area_struct *next; + struct vm_area_struct *vma = v, *next = NULL; (*pos)++; - if (vma && (vma != tail_vma) && vma->vm_next) - return vma->vm_next; + if (vma != tail_vma) + next = vma->vm_next ?: tail_vma; - next = (vma != tail_vma) ? tail_vma : NULL; if (!next) vma_stop(priv); return next; -- 2.30.2