Do defensive programming by using zfree() to initialize freed pointers
to NULL, so that eventual use after free result in a NULL pointer deref
instead of more subtle behaviour.
Also remove one NULL test before free(), as it accepts a NULL arg and we
get one line shaved not doing it explicitely.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
                if (asprintf(&new_name, "%s%su", name, sep) < 0)
                        return false;
 
-               if (evsel->name)
-                       free(evsel->name);
+               free(evsel->name);
                evsel->name = new_name;
                scnprintf(msg, msgsize, "kernel.perf_event_paranoid=%d, trying "
                          "to fall back to excluding kernel and hypervisor "
 
        if (evsel->per_pkg_mask) {
                hashmap__for_each_entry(evsel->per_pkg_mask, cur, bkt)
-                       free((void *)cur->pkey);
+                       zfree(&cur->pkey);
 
                hashmap__clear(evsel->per_pkg_mask);
        }