[PATCH 3/4] lib: fwts_devicetree: fix memory leak on data
Colin King
colin.king at canonical.com
Tue May 31 10:42:37 UTC 2016
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;
}
--
2.8.1
More information about the fwts-devel
mailing list