Skip to content

Commit

Permalink
fix reference to nil pointer (#3872)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian authored and bobz965 committed Mar 27, 2024
1 parent 5b731b2 commit 07d1210
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,15 +622,15 @@ func (c *Controller) syncSubnetCR() error {
klog.Error(err)
return err
}
for _, orisubnet := range subnets {
subnet := orisubnet.DeepCopy()
for _, cachedSubnet := range subnets {
subnet := cachedSubnet.DeepCopy()
if util.CheckProtocol(subnet.Spec.CIDRBlock) == kubeovnv1.ProtocolDual {
subnet, err = c.calcDualSubnetStatusIP(subnet)
} else {
subnet, err = c.calcSubnetStatusIP(subnet)
}
if err != nil {
klog.Errorf("failed to calculate subnet %s used ip: %v", subnet.Name, err)
klog.Errorf("failed to calculate subnet %s used ip: %v", cachedSubnet.Name, err)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error {
subnet, err = c.calcSubnetStatusIP(subnet)
}
if err != nil {
klog.Errorf("calculate subnet %s used ip failed, %v", subnet.Name, err)
klog.Errorf("calculate subnet %s used ip failed, %v", cachedSubnet.Name, err)
return err
}

Expand Down

0 comments on commit 07d1210

Please sign in to comment.