[PATCH 4/5] amptest: Fix memory leak

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

 



---
 tools/amptest.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/amptest.c b/tools/amptest.c
index 16f15bc..6192f7e 100644
--- a/tools/amptest.c
+++ b/tools/amptest.c
@@ -496,6 +496,7 @@ static bool find_amp_controller(void)
 	struct hci_dev_list_req *dl;
 	struct hci_dev_req *dr;
 	int fd, i;
+	bool result;
 
 	fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
 	if (fd < 0) {
@@ -515,8 +516,8 @@ static bool find_amp_controller(void)
 
 	if (ioctl(fd, HCIGETDEVLIST, (void *) dl) < 0) {
 		perror("Failed to get HCI device list");
-		close(fd);
-		return false;
+		result = false;
+		goto done;
 	}
 
 	for (i = 0; i< dl->dev_num; i++) {
@@ -541,9 +542,12 @@ static bool find_amp_controller(void)
 		}
 	}
 
-	close(fd);
+	result = true;
 
-	return true;
+done:
+	free(dl);
+	close(fd);
+	return result;
 }
 
 int main(int argc ,char *argv[])
-- 
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