ACK: [PATCH 4/4] devicetree: dt_base: fix resource leak on error exit paths
Alex Hung
alex.hung at canonical.com
Wed Jun 1 00:36:06 UTC 2016
On 2016-05-31 06:42 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> There are a couple of resource leaks on the error exit paths, free
> the variable output and re-work the exit paths to have a common
> resource free and return point.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/devicetree/dt_base/dt_base.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/src/devicetree/dt_base/dt_base.c b/src/devicetree/dt_base/dt_base.c
> index c325045..efb05fc 100644
> --- a/src/devicetree/dt_base/dt_base.c
> +++ b/src/devicetree/dt_base/dt_base.c
> @@ -57,10 +57,10 @@ static int dt_base_check_valid(fwts_framework *fw)
>
> static int dt_base_check_warnings(fwts_framework *fw)
> {
> - int rc, status, in_fd, out_fd;
> + int rc, status, in_fd, out_fd, ret = FWTS_ERROR;
> ssize_t in_len, out_len;
> const char *command;
> - char *output;
> + char *output = NULL;
> pid_t pid;
>
> if (!fw->fdt)
> @@ -88,18 +88,23 @@ static int dt_base_check_warnings(fwts_framework *fw)
> fwts_failed(fw, LOG_LEVEL_HIGH, "DeviceTreeBaseDTCFailed",
> "dtc reports fatal device tree errors:\n%s\n",
> output);
> - return FWTS_ERROR;
> + goto err;
> }
>
> if (out_len > 0) {
> fwts_failed(fw, LOG_LEVEL_MEDIUM, "DeviceTreeBaseDTCWarnings",
> "dtc reports warnings from device tree:\n%s\n",
> output);
> - return FWTS_ERROR;
> + goto err;
> }
>
> fwts_passed(fw, "No warnings from dtc");
> - return FWTS_OK;
> +
> + ret = FWTS_OK;
> +
> +err:
> + free(output);
> + return ret;
> }
>
> static fwts_framework_minor_test dt_base_tests[] = {
>
Acked-by: Alex Hung <alex.hung at canonical.com>
More information about the fwts-devel
mailing list