summaryrefslogtreecommitdiffstats
path: root/hcid/device.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-09-19 19:31:35 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-09-19 19:31:35 +0000
commit4c172501d839e5d7c3f46510432b731ea2768dbf (patch)
tree755b812897529332e34958a08126df8d55a4bbac /hcid/device.c
parentc7152fbc6dd127035cc22e1abe996b9e2853c9ac (diff)
close the socket before return
Diffstat (limited to 'hcid/device.c')
-rw-r--r--hcid/device.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/hcid/device.c b/hcid/device.c
index 2831fcc7..f92fa0c7 100644
--- a/hcid/device.c
+++ b/hcid/device.c
@@ -336,9 +336,11 @@ static int digi_revision(uint16_t dev_id, char *revision, size_t size)
rq.rlen = sizeof(buf);
if (hci_send_req(dd, &rq, 2000) < 0) {
+ int err = errno;
error("Can't read revision for hci%d: %s (%d)",
dev_id, strerror(errno), errno);
- return -errno;
+ hci_close_dev(dd);
+ return -err;
}
hci_close_dev(dd);
@@ -420,9 +422,11 @@ int get_device_name(uint16_t dev_id, char *name, size_t size)
}
if (hci_read_local_name(dd, sizeof(tmp), tmp, 2000) < 0) {
+ int err = errno;
error("Can't read name for hci%d: %s (%d)",
dev_id, strerror(errno), errno);
- return -errno;
+ hci_close_dev(dd);
+ return -err;
}
hci_close_dev(dd);
@@ -446,9 +450,11 @@ int set_device_name(uint16_t dev_id, const char *name)
}
if (hci_write_local_name(dd, name, 5000) < 0) {
+ int err = errno;
error("Can't write name for hci%d: %s (%d)",
dev_id, strerror(errno), errno);
- return -errno;
+ hci_close_dev(dd);
+ return -err;
}
hci_close_dev(dd);