Skip to content

Bug: Missing error return in checkIfIpIsLive causes nil pointer panic on DNS resolution failure #985

Description

@meyrevived

Bug Description

In pkg/ibm/ibmz_helpers.go, the function checkIfIpIsLive has a missing return statement after a failed net.ResolveTCPAddr call. When DNS resolution fails, the error is logged but execution continues to line 86, where server.Network() and server.String() are called on a nil *net.TCPAddr, causing a panic.

Location

File: pkg/ibm/ibmz_helpers.go
Function: checkIfIpIsLive (line 78)
Bug location: lines 83-86

Current Code

server, err := net.ResolveTCPAddr("tcp", ip+":22")
if err != nil {
    log.Error(err, "failed to resolve ip address")
}
conn, err := net.DialTimeout(server.Network(), server.String(), 5*time.Second)

Expected Behavior

When net.ResolveTCPAddr returns an error, the function should return that error immediately instead of proceeding to use the nil server pointer.

Impact

Any DNS resolution failure for an IBM Z or IBM Power host IP address will crash the controller with a nil pointer dereference panic rather than returning a clean error to the caller.

Suggested Fix

Add return err after the error log on line 84, matching the error-handling pattern used elsewhere in the same function (see lines 89 and 93).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions