Skip to content

Commit

Permalink
Merge pull request #109 from memoos/master
Browse files Browse the repository at this point in the history
Do not leave socket open in case no device can be found
  • Loading branch information
estutzenberger authored Jan 22, 2024
2 parents 5dde9f6 + 6f64bf4 commit 8c5522f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions linux/hci/socket/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func NewSocket(id int) (*Socket, error) {

req := devListRequest{devNum: hciMaxDevices}
if err = ioctl(uintptr(fd), hciGetDeviceList, uintptr(unsafe.Pointer(&req))); err != nil {
unix.Close(fd)
return nil, errors.Wrap(err, "can't get device list")
}
var msg string
Expand All @@ -84,6 +85,7 @@ func NewSocket(id int) (*Socket, error) {
}
msg = msg + fmt.Sprintf("(hci%d: %s)", id, err)
}
unix.Close(fd)
return nil, errors.Errorf("no devices available: %s", msg)
}

Expand Down

0 comments on commit 8c5522f

Please sign in to comment.