From: Oleg Nesterov <o...@redhat.com>

build_map_info() has a side effect like one need to perform
mmput() when done with the mm. Add mmput() in free_map_info()
so that user does not have to call it explicitly.

Signed-off-by: Oleg Nesterov <o...@redhat.com>
Signed-off-by: Ravi Bangoria <ravi.bango...@linux.vnet.ibm.com>
---
 kernel/events/uprobes.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 535fd39..1d439c7 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -704,6 +704,7 @@ struct map_info {
 static inline struct map_info *free_map_info(struct map_info *info)
 {
        struct map_info *next = info->next;
+       mmput(info->mm);
        kfree(info);
        return next;
 }
@@ -773,8 +774,11 @@ static inline struct map_info *free_map_info(struct 
map_info *info)
 
        goto again;
  out:
-       while (prev)
-               prev = free_map_info(prev);
+       while (prev) {
+               info = prev;
+               prev = prev->next;
+               kfree(info);
+       }
        return curr;
 }
 
@@ -824,7 +828,6 @@ static inline struct map_info *free_map_info(struct 
map_info *info)
  unlock:
                up_write(&mm->mmap_sem);
  free:
-               mmput(mm);
                info = free_map_info(info);
        }
  out:
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to