aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2014-10-09 18:25:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-09 22:25:48 -0400
commit23d54837e4f3a44ad4514d5eae8245c2250217ff (patch)
tree086ff9b97bd790748e9da7798d6714cd8fca06f6 /fs/proc
parent59b4bf12d4776c0e4f3fd5c02d942f3a0596da97 (diff)
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 <oleg@redhat.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/task_mmu.c8
1 files 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:
210static void *m_next(struct seq_file *m, void *v, loff_t *pos) 210static void *m_next(struct seq_file *m, void *v, loff_t *pos)
211{ 211{
212 struct proc_maps_private *priv = m->private; 212 struct proc_maps_private *priv = m->private;
213 struct vm_area_struct *vma = v;
214 struct vm_area_struct *tail_vma = priv->tail_vma; 213 struct vm_area_struct *tail_vma = priv->tail_vma;
215 struct vm_area_struct *next; 214 struct vm_area_struct *vma = v, *next = NULL;
216 215
217 (*pos)++; 216 (*pos)++;
218 if (vma && (vma != tail_vma) && vma->vm_next) 217 if (vma != tail_vma)
219 return vma->vm_next; 218 next = vma->vm_next ?: tail_vma;
220 219
221 next = (vma != tail_vma) ? tail_vma : NULL;
222 if (!next) 220 if (!next)
223 vma_stop(priv); 221 vma_stop(priv);
224 return next; 222 return next;