Skip to content

Commit 10da74a

Browse files
authored
Merge pull request #1012 from hqhq/fix_null_point_reference
Fix null point reference panic
2 parents b790765 + aa2dd02 commit 10da74a

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

libcontainer/specconv/spec_linux.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,25 +395,41 @@ func createCgroupConfig(name string, useSystemdCgroup bool, spec *specs.Spec) (*
395395
}
396396
if r.BlockIO.ThrottleReadBpsDevice != nil {
397397
for _, td := range r.BlockIO.ThrottleReadBpsDevice {
398-
throttleDevice := configs.NewThrottleDevice(td.Major, td.Minor, *td.Rate)
398+
var rate uint64
399+
if td.Rate != nil {
400+
rate = *td.Rate
401+
}
402+
throttleDevice := configs.NewThrottleDevice(td.Major, td.Minor, rate)
399403
c.Resources.BlkioThrottleReadBpsDevice = append(c.Resources.BlkioThrottleReadBpsDevice, throttleDevice)
400404
}
401405
}
402406
if r.BlockIO.ThrottleWriteBpsDevice != nil {
403407
for _, td := range r.BlockIO.ThrottleWriteBpsDevice {
404-
throttleDevice := configs.NewThrottleDevice(td.Major, td.Minor, *td.Rate)
408+
var rate uint64
409+
if td.Rate != nil {
410+
rate = *td.Rate
411+
}
412+
throttleDevice := configs.NewThrottleDevice(td.Major, td.Minor, rate)
405413
c.Resources.BlkioThrottleWriteBpsDevice = append(c.Resources.BlkioThrottleWriteBpsDevice, throttleDevice)
406414
}
407415
}
408416
if r.BlockIO.ThrottleReadIOPSDevice != nil {
409417
for _, td := range r.BlockIO.ThrottleReadIOPSDevice {
410-
throttleDevice := configs.NewThrottleDevice(td.Major, td.Minor, *td.Rate)
418+
var rate uint64
419+
if td.Rate != nil {
420+
rate = *td.Rate
421+
}
422+
throttleDevice := configs.NewThrottleDevice(td.Major, td.Minor, rate)
411423
c.Resources.BlkioThrottleReadIOPSDevice = append(c.Resources.BlkioThrottleReadIOPSDevice, throttleDevice)
412424
}
413425
}
414426
if r.BlockIO.ThrottleWriteIOPSDevice != nil {
415427
for _, td := range r.BlockIO.ThrottleWriteIOPSDevice {
416-
throttleDevice := configs.NewThrottleDevice(td.Major, td.Minor, *td.Rate)
428+
var rate uint64
429+
if td.Rate != nil {
430+
rate = *td.Rate
431+
}
432+
throttleDevice := configs.NewThrottleDevice(td.Major, td.Minor, rate)
417433
c.Resources.BlkioThrottleWriteIOPSDevice = append(c.Resources.BlkioThrottleWriteIOPSDevice, throttleDevice)
418434
}
419435
}

0 commit comments

Comments
 (0)