浏览代码

devmapper: Fix UnmountDevice for non-existing device

Properly error out if passed an id that doesn't exist.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Alexander Larsson 11 年之前
父节点
当前提交
304e33a2fe
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      graphdriver/devmapper/deviceset.go

+ 3 - 0
graphdriver/devmapper/deviceset.go

@@ -847,6 +847,9 @@ func (devices *DeviceSet) UnmountDevice(hash string, mode UnmountMode) error {
 	defer devices.Unlock()
 	defer devices.Unlock()
 
 
 	info := devices.Devices[hash]
 	info := devices.Devices[hash]
+	if info == nil {
+		return fmt.Errorf("UnmountDevice: no such device %s\n", hash)
+	}
 
 
 	if mode == UnmountFloat {
 	if mode == UnmountFloat {
 		if info.floating {
 		if info.floating {