perf cs-etm: Refactor error path in cs_etm_decoder__new()
authorMathieu Poirier <mathieu.poirier@linaro.org>
Fri, 24 May 2019 17:34:57 +0000 (11:34 -0600)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 10 Jun 2019 18:50:01 +0000 (15:50 -0300)
There is no point in having two different error goto statement since the
openCSD API to free a decoder handles NULL pointers.  As such function
cs_etm_decoder__free() can be called to deal with all aspect of freeing
decoder memory.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20190524173508.29044-7-mathieu.poirier@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c

index 39fe21e1cf930108adeec730cabc77ca76bc7f78..5dafec421b0d47099eb3d8160870e8f5d0aa5620 100644 (file)
@@ -577,7 +577,7 @@ cs_etm_decoder__new(int num_cpu, struct cs_etm_decoder_params *d_params,
        /* init library print logging support */
        ret = cs_etm_decoder__init_def_logger_printing(d_params, decoder);
        if (ret != 0)
-               goto err_free_decoder_tree;
+               goto err_free_decoder;
 
        /* init raw frame logging if required */
        cs_etm_decoder__init_raw_frame_logging(d_params, decoder);
@@ -587,15 +587,13 @@ cs_etm_decoder__new(int num_cpu, struct cs_etm_decoder_params *d_params,
                                                         &t_params[i],
                                                         decoder);
                if (ret != 0)
-                       goto err_free_decoder_tree;
+                       goto err_free_decoder;
        }
 
        return decoder;
 
-err_free_decoder_tree:
-       ocsd_destroy_dcd_tree(decoder->dcd_tree);
 err_free_decoder:
-       free(decoder);
+       cs_etm_decoder__free(decoder);
        return NULL;
 }