lkml.org 
[lkml]   [2018]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v3 3/9] Uprobe: Move mmput() into free_map_info()
    Date
    From: Oleg Nesterov <oleg@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 <oleg@redhat.com>
    Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.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
    \
     
     \ /
      Last update: 2018-04-17 06:35    [W:4.347 / U:0.644 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site