perf bpf: Defer freeing string after possible strlen() on it
[linux-2.6-microblaze.git] / tools / perf / util / bpf-loader.c
index 7ecfaac..16ec605 100644 (file)
@@ -1220,9 +1220,10 @@ bpf__obj_config_map(struct bpf_object *obj,
        pr_debug("ERROR: Invalid map config option '%s'\n", map_opt);
        err = -BPF_LOADER_ERRNO__OBJCONF_MAP_OPT;
 out:
-       free(map_name);
        if (!err)
                *key_scan_pos += strlen(map_opt);
+
+       free(map_name);
        return err;
 }