lkml.org 
[lkml]   [2011]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[003/165] kmemleak: Do not return a pointer to an object that kmemleak did not get
    2.6.39-stable review patch.  If anyone has any objections, please let us know.

    ------------------
    Content-Length: 1145
    Lines: 37

    From: Catalin Marinas <catalin.marinas@arm.com>

    commit 52c3ce4ec5601ee383a14f1485f6bac7b278896e upstream.

    The kmemleak_seq_next() function tries to get an object (and increment
    its use count) before returning it. If it could not get the last object
    during list traversal (because it may have been freed), the function
    should return NULL rather than a pointer to such object that it did not
    get.

    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Reported-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
    Acked-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

    ---
    mm/kmemleak.c | 7 +++++--
    1 file changed, 5 insertions(+), 2 deletions(-)

    --- a/mm/kmemleak.c
    +++ b/mm/kmemleak.c
    @@ -1414,9 +1414,12 @@ static void *kmemleak_seq_next(struct se
    ++(*pos);

    list_for_each_continue_rcu(n, &object_list) {
    - next_obj = list_entry(n, struct kmemleak_object, object_list);
    - if (get_object(next_obj))
    + struct kmemleak_object *obj =
    + list_entry(n, struct kmemleak_object, object_list);
    + if (get_object(obj)) {
    + next_obj = obj;
    break;
    + }
    }

    put_object(prev_obj);



    \
     
     \ /
      Last update: 2011-06-01 10:19    [W:2.486 / U:25.648 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site