lkml.org 
[lkml]   [2021]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] perf stat: Fix NULL vs IS_ERR() checking in check_per_pkg
    Date
    The hashmap__new() function does not return NULL on errors. It returns
    ERR_PTR(-ENOMEM). Using IS_ERR() to check the return value
    to fix this.

    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    ---
    tools/perf/util/stat.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
    index 09ea334586f2..a77052680087 100644
    --- a/tools/perf/util/stat.c
    +++ b/tools/perf/util/stat.c
    @@ -311,8 +311,8 @@ static int check_per_pkg(struct evsel *counter,

    if (!mask) {
    mask = hashmap__new(pkg_id_hash, pkg_id_equal, NULL);
    - if (!mask)
    - return -ENOMEM;
    + if (IS_ERR(mask))
    + return PTR_ERR(mask);

    counter->per_pkg_mask = mask;
    }
    --
    2.17.1
    \
     
     \ /
      Last update: 2021-12-12 05:24    [W:5.292 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site