[PATCH 2/5] hcidump: Fix memory leak

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

 



Memory pointed by frm.data variable was not freed in both failure and
success flows.
---
 tools/hcidump.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/hcidump.c b/tools/hcidump.c
index 50123d2..2bbc207 100644
--- a/tools/hcidump.c
+++ b/tools/hcidump.c
@@ -309,7 +309,7 @@ static void read_dump(int fd)
 		if (err < 0)
 			goto failed;
 		if (!err)
-			return;
+			goto done;
 
 		if (parser.flags & DUMP_PKTLOG) {
 			switch (ph.type) {
@@ -407,7 +407,7 @@ static void read_dump(int fd)
 		if (err < 0)
 			goto failed;
 		if (!err)
-			return;
+			goto done;
 
 		frm.ptr = frm.data;
 		frm.len = frm.data_len;
@@ -432,8 +432,13 @@ static void read_dump(int fd)
 		parse(&frm);
 	}
 
+done:
+	free(frm.data);
+	return;
+
 failed:
 	perror("Read failed");
+	free(frm.data);
 	exit(1);
 }
 
-- 
1.8.5.3

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




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux