[systemd-devel] [PATCH 1/2] udev: don't call fclose on NULL in is_pci_multifunction

Lukas Nykryn lnykryn at redhat.com
Wed Jan 9 08:10:56 PST 2013


---
 src/udev/udev-builtin-net_id.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index d5db762..7033d05 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -136,7 +136,7 @@ static int dev_pci_onboard(struct udev_device *dev, struct netnames *names) {
 /* read the 256 bytes PCI configuration space to check the multi-function bit */
 static bool is_pci_multifunction(struct udev_device *dev) {
         char filename[256];
-        FILE *f;
+        FILE *f = NULL;
         char config[64];
         bool multi = false;
 
@@ -151,7 +151,8 @@ static bool is_pci_multifunction(struct udev_device *dev) {
         if ((config[PCI_HEADER_TYPE] & 0x80) != 0)
                 multi = true;
 out:
-        fclose(f);
+        if(f)
+                fclose(f);
         return multi;
 }
 
-- 
1.7.11.7



More information about the systemd-devel mailing list