[PATCH] Define the fd variable before it can ever be referenced (#496930).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 storage/formats/__init__.py |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/storage/formats/__init__.py b/storage/formats/__init__.py
index e68684c..46a6576 100644
--- a/storage/formats/__init__.py
+++ b/storage/formats/__init__.py
@@ -246,6 +246,8 @@ class DeviceFormat(object):
         # hope that it will wipe any metadata from filesystems that
         # previously occupied this device
         log.debug("zeroing out beginning and end of %s..." % self.device)
+        fd = None
+
         try:
             fd = os.open(self.device, os.O_RDWR)
             buf = '\0' * 1024 * 1024
@@ -258,10 +260,13 @@ class DeviceFormat(object):
                 pass
             else:
                 log.error("error zeroing out %s: %s" % (self.device, e))
-            os.close(fd)
+
+            if fd:
+                os.close(fd)
         except Exception as e:
             log.error("error zeroing out %s: %s" % (self.device, e))
-            os.close(fd)
+            if fd:
+                os.close(fd)
 
         self.exists = False
 
-- 
1.6.1.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux