lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YbdF4FtPY77Y6faW@kernel.org>
Date:   Mon, 13 Dec 2021 10:08:48 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Miaoqian Lin <linmq006@...il.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Ian Rogers <irogers@...gle.com>,
        Andi Kleen <ak@...ux.intel.com>,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf expr: Fix missing check for return value of
 hashmap__new

Em Mon, Dec 13, 2021 at 10:06:02AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Sun, Dec 12, 2021 at 06:25:02AM +0000, Miaoqian Lin escreveu:
> > The hashmap__new() function may return ERR_PTR(-ENOMEM) when malloc
> > fails, add IS_ERR checking for ctx->ids.
> > 
> > Signed-off-by: Miaoqian Lin <linmq006@...il.com>
> 
> Thanks, applied.

I take that back, kfree()? Are you compile testing this?

  CC      /tmp/build/perf/util/expr.o
util/expr.c: In function ‘expr__ctx_new’:
util/expr.c:302:13: error: implicit declaration of function ‘IS_ERR’ [-Werror=implicit-function-declaration]
  302 |         if (IS_ERR(ctx->ids)) {
      |             ^~~~~~
util/expr.c:303:17: error: implicit declaration of function ‘kfree’; did you mean ‘free’? [-Werror=implicit-function-declaration]
  303 |                 kfree(ctx);
      |                 ^~~~~
      |                 free
cc1: all warnings being treated as errors

I had to fix it applying this on top, please compile test your patches.

- Arnaldo

diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
index c94c9ea30d1abd6a..254601060b392c42 100644
--- a/tools/perf/util/expr.c
+++ b/tools/perf/util/expr.c
@@ -12,6 +12,7 @@
 #include "expr-bison.h"
 #include "expr-flex.h"
 #include "smt.h"
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/zalloc.h>
 #include <ctype.h>
@@ -300,7 +301,7 @@ struct expr_parse_ctx *expr__ctx_new(void)
 
 	ctx->ids = hashmap__new(key_hash, key_equal, NULL);
 	if (IS_ERR(ctx->ids)) {
-		kfree(ctx);
+		free(ctx);
 		return NULL;
 	}
 	ctx->runtime = 0;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ