Arnaldo Carvalho de Melo 31ded1535e perf bpf: Defer freeing string after possible strlen() on it
This was detected by the gcc in Fedora Rawhide's gcc:

  50    11.01 fedora:rawhide                : FAIL gcc version 12.0.1 20220205 (Red Hat 12.0.1-0) (GCC)
        inlined from 'bpf__config_obj' at util/bpf-loader.c:1242:9:
    util/bpf-loader.c:1225:34: error: pointer 'map_opt' may be used after 'free' [-Werror=use-after-free]
     1225 |                 *key_scan_pos += strlen(map_opt);
          |                                  ^~~~~~~~~~~~~~~
    util/bpf-loader.c:1223:9: note: call to 'free' here
     1223 |         free(map_name);
          |         ^~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

So do the calculations on the pointer before freeing it.

Fixes: 04f9bf2bac72480c ("perf bpf-loader: Add missing '*' for key_scan_pos")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>
Link: https://lore.kernel.org/lkml/Yg1VtQxKrPpS3uNA@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-02-17 07:15:09 -03:00
..
2019-02-19 16:11:56 -03:00
2019-02-19 16:11:56 -03:00
2022-01-12 14:28:23 -03:00
2021-09-03 08:15:10 -03:00
2021-04-29 10:30:58 -03:00
2021-08-11 09:35:44 -03:00
2021-08-11 09:35:44 -03:00
2022-01-12 14:28:23 -03:00
2022-01-12 14:28:23 -03:00
2022-01-12 14:28:23 -03:00
2021-11-07 12:27:38 -03:00
2022-01-12 14:28:23 -03:00
2021-11-07 12:27:38 -03:00
2021-02-03 13:10:44 -03:00
2021-07-15 17:30:22 -03:00
2022-01-15 17:07:05 -03:00
2022-01-12 14:28:23 -03:00
2022-01-02 11:29:05 -03:00
2021-09-17 08:55:00 -03:00
2021-11-07 12:27:38 -03:00
2019-01-25 15:12:09 +01:00
2022-01-12 14:28:23 -03:00
2022-01-12 14:28:23 -03:00
2020-10-14 13:34:26 -03:00
2021-02-17 15:15:06 -03:00
2021-02-17 15:15:06 -03:00
2021-11-13 18:11:51 -03:00
2020-04-18 09:05:01 -03:00
2020-04-18 09:05:01 -03:00