Skip to content

Commit

Permalink
mp707: close device handles
Browse files Browse the repository at this point in the history
This should be a good enough example of how not to end with fd leak
  • Loading branch information
nradchenko committed Nov 3, 2021
1 parent 85afce9 commit 67a3862
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/mp707/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func main() {
}

for _, device := range devices {
defer device.Close()

if *deviceId > 0 {
if device.GetId() != uint8(*deviceId) {
log.Println("skipping device", device.GetId())
Expand Down

0 comments on commit 67a3862

Please sign in to comment.