crc-org / vfkit

Apache License 2.0
119 stars 23 forks source link

Fix crash in timesync code #68

Closed cfergeau closed 9 months ago

cfergeau commented 9 months ago

When ConnectVSockSync fails in watchWakeupNotifications(), the returned net.Conn contains a nil value, but is not a nil interface (ie checking it for == nil returns false). This means we'll try to call Close() on the connection, which will cause a nil pointer dereference. See https://go.dev/doc/faq#nil_error and https://groups.google.com/g/golang-nuts/c/wnH302gBa4I for details about this behaviour.

This bug is fixed by returning a nil interface when vsockDevice.Connect(uint32(port)) returns an error.

praveenkumar commented 9 months ago

/lgtm /approve

openshift-ci[bot] commented 9 months ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: praveenkumar Once this PR has been reviewed and has the lgtm label, please ask for approval from cfergeau. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/crc-org/vfkit/blob/main/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment