[libvirt] [PATCH 2/3] util: Fix error path in virSCSIVHostOpenVhostSCSI

John Ferlan posted 3 patches 7 years, 5 months ago
[libvirt] [PATCH 2/3] util: Fix error path in virSCSIVHostOpenVhostSCSI
Posted by John Ferlan 7 years, 5 months ago
We cannot be sure someone initialized the passed *vhostfd and we
certainly don't want or need to be calling VIR_FORCE_CLOSE on what
probably is -1. So let's just return -1 immediately.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/util/virscsivhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c
index dc7df757a..d6fbf5ed5 100644
--- a/src/util/virscsivhost.c
+++ b/src/util/virscsivhost.c
@@ -87,7 +87,7 @@ int
 virSCSIVHostOpenVhostSCSI(int *vhostfd)
 {
     if (!virFileExists(VHOST_SCSI_DEVICE))
-        goto error;
+        return -1;
 
     *vhostfd = open(VHOST_SCSI_DEVICE, O_RDWR);
 
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/3] util: Fix error path in virSCSIVHostOpenVhostSCSI
Posted by Eric Farman 7 years, 5 months ago

On 12/12/2017 09:22 AM, John Ferlan wrote:
> We cannot be sure someone initialized the passed *vhostfd and we
> certainly don't want or need to be calling VIR_FORCE_CLOSE on what
> probably is -1. So let's just return -1 immediately.
> 
> Signed-off-by: John Ferlan <jferlan@redhat.com>

Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>

> ---
>   src/util/virscsivhost.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c
> index dc7df757a..d6fbf5ed5 100644
> --- a/src/util/virscsivhost.c
> +++ b/src/util/virscsivhost.c
> @@ -87,7 +87,7 @@ int
>   virSCSIVHostOpenVhostSCSI(int *vhostfd)
>   {
>       if (!virFileExists(VHOST_SCSI_DEVICE))
> -        goto error;
> +        return -1;
> 
>       *vhostfd = open(VHOST_SCSI_DEVICE, O_RDWR);
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list