ACK: [PATCH 3/4] lib: fwts_devicetree: fix memory leak on data
ivanhu
ivan.hu at canonical.com
Fri Jun 3 02:34:44 UTC 2016
On 05/31/2016 06:42 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> There is a resource leak on the error exit path on variable data;
> so free it.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/lib/src/fwts_devicetree.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_devicetree.c b/src/lib/src/fwts_devicetree.c
> index baa4e6b..5978ab9 100644
> --- a/src/lib/src/fwts_devicetree.c
> +++ b/src/lib/src/fwts_devicetree.c
> @@ -27,7 +27,7 @@ static const char *devicetree_fs_path = "/sys/firmware/devicetree/base";
>
> int fwts_devicetree_read(fwts_framework *fwts)
> {
> - char *command, *data;
> + char *command, *data = NULL;
> int fd, rc, status;
> ssize_t len;
> pid_t pid;
> @@ -56,6 +56,7 @@ int fwts_devicetree_read(fwts_framework *fwts)
>
> if (!WIFEXITED(status) || WEXITSTATUS(status) != 0 || len == 0) {
> fprintf(stderr, "Cannot read devicetree data: dtc failed\n");
> + free(data);
> return FWTS_ERROR;
> }
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list