Skip to content

Commit 3fa070a

Browse files
committed
Fix nil pointer dereference in the azure provider
PlatformFaultDomain in the VM properties returned by Azure will be nil if the VM is not part of an availability set. Use to.Int32() from the Azure SDK to safely retrieve its value.
1 parent bd4c9a2 commit 3fa070a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

staging/src/k8s.io/legacy-cloud-providers/azure/azure_standard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ func (as *availabilitySet) GetZoneByNodeName(name string) (cloudprovider.Zone, e
463463
failureDomain = as.makeZone(to.String(vm.Location), zoneID)
464464
} else {
465465
// Availability zone is not used for the node, falling back to fault domain.
466-
failureDomain = strconv.Itoa(int(*vm.VirtualMachineProperties.InstanceView.PlatformFaultDomain))
466+
failureDomain = strconv.Itoa(int(to.Int32(vm.VirtualMachineProperties.InstanceView.PlatformFaultDomain)))
467467
}
468468

469469
zone := cloudprovider.Zone{

0 commit comments

Comments
 (0)