diff --git a/src/freedreno/decode/cffdec.c b/src/freedreno/decode/cffdec.c index 05eebf0ac0f..a5706f16999 100644 --- a/src/freedreno/decode/cffdec.c +++ b/src/freedreno/decode/cffdec.c @@ -859,10 +859,7 @@ dump_register_val(uint32_t regbase, uint32_t dword, int level) printf("%s<%04x>: %08x\n", levels[level], regbase, dword); } - if (info) { - free(info->name); - free(info); - } + rnn_reginfo_free(info); } static void diff --git a/src/freedreno/decode/crashdec-mempool.c b/src/freedreno/decode/crashdec-mempool.c index 98404ffb8b4..51f9159c1af 100644 --- a/src/freedreno/decode/crashdec-mempool.c +++ b/src/freedreno/decode/crashdec-mempool.c @@ -39,6 +39,7 @@ dump_mem_pool_reg_write(unsigned reg, uint32_t data, unsigned context, printf("\t\t\t"); dump_register(rnn_pipe, reg, data); } + rnn_reginfo_free(info); } else { printf("\t\twrite %s (%05x) context %d\n", regname(reg, 1), reg, context); dump_register_val(reg, data, 2); diff --git a/src/freedreno/decode/crashdec.c b/src/freedreno/decode/crashdec.c index 1da27c63be3..640f8d49d2c 100644 --- a/src/freedreno/decode/crashdec.c +++ b/src/freedreno/decode/crashdec.c @@ -469,6 +469,7 @@ dump_register(struct rnn *rnn, uint32_t offset, uint32_t value) } else { printf("<%04x>: %08x\n", offset, value); } + rnn_reginfo_free(info); } static void diff --git a/src/freedreno/decode/rddecompiler.c b/src/freedreno/decode/rddecompiler.c index 0669148fdc2..593cfd641e9 100644 --- a/src/freedreno/decode/rddecompiler.c +++ b/src/freedreno/decode/rddecompiler.c @@ -266,6 +266,8 @@ decompile_register(uint32_t regbase, uint32_t *dwords, uint16_t cnt, int level) printlvl(level, "pkt4(cs, %u, (%u), %u);\n", regbase, cnt, dword); } + rnn_reginfo_free(info); + return 1; } diff --git a/src/freedreno/decode/rnnutil.c b/src/freedreno/decode/rnnutil.c index d280389eafc..6c7b0009bc1 100644 --- a/src/freedreno/decode/rnnutil.c +++ b/src/freedreno/decode/rnnutil.c @@ -144,12 +144,22 @@ rnn_regname(struct rnn *rnn, uint32_t regbase, int color) return NULL; } +/* call rnn_reginfo_free() to free the result */ struct rnndecaddrinfo * rnn_reginfo(struct rnn *rnn, uint32_t regbase) { return rnndec_decodeaddr(rnn->vc, finddom(rnn, regbase), regbase, 0); } +void +rnn_reginfo_free(struct rnndecaddrinfo *info) +{ + if (!info) + return; + free(info->name); + free(info); +} + const char * rnn_enumname(struct rnn *rnn, const char *name, uint32_t val) { diff --git a/src/freedreno/decode/rnnutil.h b/src/freedreno/decode/rnnutil.h index b2883235da6..665109690b2 100644 --- a/src/freedreno/decode/rnnutil.h +++ b/src/freedreno/decode/rnnutil.h @@ -55,6 +55,7 @@ void rnn_load(struct rnn *rnn, const char *gpuname); uint32_t rnn_regbase(struct rnn *rnn, const char *name); const char *rnn_regname(struct rnn *rnn, uint32_t regbase, int color); struct rnndecaddrinfo *rnn_reginfo(struct rnn *rnn, uint32_t regbase); +void rnn_reginfo_free(struct rnndecaddrinfo *info); const char *rnn_enumname(struct rnn *rnn, const char *name, uint32_t val); struct rnndelem *rnn_regelem(struct rnn *rnn, const char *name); diff --git a/src/freedreno/decode/script.c b/src/freedreno/decode/script.c index c2bf75dd851..956102b9b31 100644 --- a/src/freedreno/decode/script.c +++ b/src/freedreno/decode/script.c @@ -393,10 +393,7 @@ l_rnn_reg_meta_tostring(lua_State *L) } lua_pushstring(L, decoded); free(decoded); - if (info) { - free(info->name); - free(info); - } + rnn_reginfo_free(info); return 1; } @@ -519,10 +516,7 @@ l_rnn_regval(lua_State *L) } lua_pushstring(L, decoded); free(decoded); - if (info) { - free(info->name); - free(info); - } + rnn_reginfo_free(info); return 1; }