Project

General

Profile

Bug #8486

libdiskmgt: memory leak in slice_get_stats()

Added by Yuri Pankov over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
lib - userland libraries
Start date:
2017-07-13
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:

Description

ADDR          BUFADDR        TIMESTAMP           THREAD
                            CACHE          LASTLOG         CONTENTS
         a951af8          a950278     7f3f1e662027               13
                          9b28010                0                0
                 libumem.so.1`umem_cache_alloc_debug+0x1fe
                 libumem.so.1`umem_cache_alloc+0x99
                 libumem.so.1`umem_alloc+0x50
                 libumem.so.1`umem_malloc+0x36
                 libnvpair.so.1`nv_alloc_sys+0x1b
                 libnvpair.so.1`nv_priv_alloc+0x13
                 libnvpair.so.1`nvlist_xalloc+0x1c
                 libnvpair.so.1`nvlist_alloc+0x26
                 libdiskmgt.so.1`slice_get_stats+0x47
                 libdiskmgt.so.1`dm_get_stats+0x100
                 libdiskmgt.so.1`dm_get_slice_stats+0x53
                 libdiskmgt.so.1`dm_inuse+0xfc

There are clearly visible memory leaks in slice_get_stats() when nvlist is allocated and is not freed in case something fails.

For the callers:
- slice_get_stats() is only called from dm_get_stats(), returning nvlist as is.
- dm_get_stats() is called from dm_get_slice_stats(), passing back nvlist pointer by reference, and libzfs_jni`get_slice_use() does free the nvlist.
- dm_get_slice_stats() is only called from dm_inuse(), which does free the nvlist.

History

#1

Updated by Electric Monk about 2 years ago

  • % Done changed from 50 to 100
  • Status changed from In Progress to Closed

git commit 83e86541459022f059e0bf50ebbc33fc8ec2d62e

commit  83e86541459022f059e0bf50ebbc33fc8ec2d62e
Author: Yuri Pankov <yuri.pankov@nexenta.com>
Date:   2017-07-28T19:06:56.000Z

    8486 libdiskmgt: memory leak in slice_get_stats()
    Reviewed by: Dan Fields <dan.fields@nexenta.com>
    Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
    Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
    Reviewed by: Toomas Soome <tsoome@me.com>
    Reviewed by: Igor Kozhukhov <igor@dilos.org>
    Approved by: Robert Mustacchi <rm@joyent.com>

Also available in: Atom PDF