chiark / gitweb /
udev: don't call fclose on NULL in is_pci_multifunction
authorLukas Nykryn <lnykryn@redhat.com>
Wed, 9 Jan 2013 16:10:56 +0000 (17:10 +0100)
committerKay Sievers <kay@vrfy.org>
Wed, 9 Jan 2013 16:14:40 +0000 (17:14 +0100)
src/udev/udev-builtin-net_id.c

index 1975c6d62c5af6e7db918a4ca45d817f47fef4ea..7c9564f4cdb3056eb62b86a9356898917851a4b9 100644 (file)
@@ -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];
 /* 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;
 
         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:
         if ((config[PCI_HEADER_TYPE] & 0x80) != 0)
                 multi = true;
 out:
-        fclose(f);
+        if(f)
+                fclose(f);
         return multi;
 }
 
         return multi;
 }