diff --git a/tools/amptest.c b/tools/amptest.c
index 16f15bc..6192f7e 100644
--- a/tools/amptest.c
+++ b/tools/amptest.c
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) {
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++) {
}
}
- close(fd);
+ result = true;
- return true;
+done:
+ free(dl);
+ close(fd);
+ return result;
}
int main(int argc ,char *argv[])