Skip to content

Commit a71a606

Browse files
committed
Add check on returned volumeIds
Add string array length check on returned volumeIds to avoid panic issue
1 parent 20ae0e8 commit a71a606

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/mount-manager/safe-mounter_windows.go

+3
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ func (mounter *CSIProxyMounter) FormatAndMount(source string, target string, fst
242242
return err
243243
}
244244
// TODO: consider partitions and choose the right partition.
245+
if len(volumeIdResponse.VolumeIds) == 0 {
246+
return fmt.Errorf("ListVolumesOnDisk does not return any volumes")
247+
}
245248
volumeID := volumeIdResponse.VolumeIds[0]
246249
isVolumeFormattedRequest := &volumeapi.IsVolumeFormattedRequest{
247250
VolumeId: volumeID,

0 commit comments

Comments
 (0)