Re: [PATCH] fdtput.c: Fix memory leak.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Le 13/07/2016 04:50, David Gibson a écrit :
On Wed, Jul 13, 2016 at 12:36:21AM +0200, Jean-Christophe Dubois wrote:
CID 132821 (#1 of 1): Resource leak (RESOURCE_LEAK)
12. leaked_storage: Variable value going out of scope leaks the storage it points to.

Signed-off-by: Jean-Christophe Dubois <jcd@xxxxxxxxxxxxxxx>
As with fdtput, because the program exits immediately after, there's
really no point to this free().
As we are already freeing "blob" and on a correctness point of view (and to be consistent) we should also free "value".



---
  fdtput.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fdtput.c b/fdtput.c
index 9b15c53..db65e96 100644
--- a/fdtput.c
+++ b/fdtput.c
@@ -328,7 +328,7 @@ static int delete_node(char *blob, const char *node_name)
  static int do_fdtput(struct display_info *disp, const char *filename,
  		    char **arg, int arg_count)
  {
-	char *value;
+	char *value = NULL;
  	char *blob;
  	char *node;
  	int len, ret = 0;
@@ -374,6 +374,11 @@ static int do_fdtput(struct display_info *disp, const char *filename,
  	}
free(blob);
+
+	if (value) {
+		free(value);
+	}
+
  	return ret;
  }

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux