[vhostmd PATCH 16/18] vhostmd: Check for valide file handle before calling close

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

 



>From coverity scan

vhostmd-1.1/vhostmd/vhostmd.c:778: var_tested_neg: Assigning: "fd" = a negative value.
vhostmd-1.1/vhostmd/vhostmd.c:845: negative_returns: "fd" is passed to a parameter that cannot be negative.
  843|      free(dir);
  844|      free(buf);
  845|->    close(fd);
  846|      return -1;
  847|   }

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
 vhostmd/vhostmd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c
index 1600a87..1395bc5 100644
--- a/vhostmd/vhostmd.c
+++ b/vhostmd/vhostmd.c
@@ -860,7 +860,8 @@ static int metrics_disk_create(void)
  error:
    free(dir);
    free(buf);
-   close(fd);
+   if (fd != -1)
+       close(fd);
    return -1;
 }
 
-- 
2.16.4


_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux