From df1f5839038692a7569427c7e071c5ef8ad1161e Mon Sep 17 00:00:00 2001 From: Andreas Florath Date: Sat, 4 Feb 2017 19:21:48 +0000 Subject: [PATCH] Check return of _load_state In error scenarios there might be no loadable state available. This patch adds some robustness handling this scenarios by checking the result and possible bailing out. Change-Id: I02e2731b14bec22c22db08d60d8d15db1911a84e Signed-off-by: Andreas Florath --- diskimage_builder/block_device/blockdevice.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/diskimage_builder/block_device/blockdevice.py b/diskimage_builder/block_device/blockdevice.py index 97e01434..6f3a3a91 100644 --- a/diskimage_builder/block_device/blockdevice.py +++ b/diskimage_builder/block_device/blockdevice.py @@ -179,6 +179,8 @@ local_loop: """Cleanup all remaining relicts - in good case""" dg, reverse_order, state = self._load_state() + if dg is None: + return 0 for node in reverse_order: node.cleanup(state) @@ -191,6 +193,8 @@ local_loop: """Cleanup all remaining relicts - in case of an error""" dg, reverse_order, state = self._load_state() + if dg is None: + return 0 for node in reverse_order: node.delete(state)