From 5cf64bb53f977ef07e5d93df005db045b1380678 Mon Sep 17 00:00:00 2001 From: Derek Su Date: Fri, 29 Nov 2024 02:41:43 +0000 Subject: [PATCH] fix: fix potential nil dereference error Longhorn 9244 Signed-off-by: Derek Su --- pkg/client/client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/client/client.go b/pkg/client/client.go index b67f20ea..110069f8 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -229,7 +229,10 @@ func (c *SPDKClient) ReplicaRebuildingSrcStart(srcReplicaName, dstReplicaName, d DstReplicaAddress: dstReplicaAddress, ExposedSnapshotName: exposedSnapshotName, }) - return resp.ExposedSnapshotLvolAddress, errors.Wrapf(err, "failed to start replica rebuilding src %s for rebuilding replica %s(%s)", srcReplicaName, dstReplicaName, dstReplicaAddress) + if err != nil { + return "", errors.Wrapf(err, "failed to start replica rebuilding src %s for rebuilding replica %s(%s)", srcReplicaName, dstReplicaName, dstReplicaAddress) + } + return resp.ExposedSnapshotLvolAddress, nil } // ReplicaRebuildingSrcFinish asks the source replica to stop exposing the parent snapshot of the head (if necessary) and clean up the dst replica related cache