summaryrefslogtreecommitdiff
path: root/tools/amptest.c
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2014-02-07 19:28:44 -0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-02-17 13:39:17 +0200
commit2b440236f99524cc42e50b98f8b6b1510330c32e (patch)
tree382d806cd90d3f39653f424aec87ad06fe22ff10 /tools/amptest.c
parent19206e7bb0de88e00fa4d17db951ace3d4e84fac (diff)
downloadbluez-2b440236f99524cc42e50b98f8b6b1510330c32e.tar.gz
amptest: Fix memory leak
Diffstat (limited to 'tools/amptest.c')
-rw-r--r--tools/amptest.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/amptest.c b/tools/amptest.c
index 16f15bc87..6192f7e67 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[])