pci-assign: Fix warning from coverity (argument cannot be negative)
PATCH 1/1 pci-assign: Fix warning from coverity (argument cannot be negative)
Coverity warns because function monitor_fd_param can return a negative value which might be passed to function read.
This won't happen because dev->config_fd will only be negative (-1) when local_err is set.
Signed-off-by Stefan Weil <[email protected]>
--- hw/i386/kvm/pci-assign.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/kvm/pci-assign.c +1 -1
@@ -554,7 +554,7 @@ static void get_real_device(AssignedDevice *pci_dev, Error **errp)if (pci_dev->configfd_name && *pci_dev->configfd_name) { dev->config_fd =monitor_fd_param (cur_mon, pci_dev->configfd_name, &local_err); -if (local_err) { +if (dev->config_fd <0 ) {error_propagate (errp, local_err);return ; }
Signature · 1 line
1.7.10.4
Quoted 5 lines · Stefan Weil
Coverity warns because function
monitor_fd_paramcan return a negative value which might be passed to function read.This won't happen because
dev->config_fdwill only be negative (-1) whenlocal_erris set.
Yes.
Quoted 12 lines
Signed-off-by Stefan Weil <[email protected]>--- hw/i386/kvm/pci-assign.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/i386/kvm/pci-assign.c +0
-0
hw/i386/kvm/pci-assign.c static void get_real_device(AssignedDevice *pci_dev, Error **errp) · line 560
Quoted 8 lines
hw/i386/kvm/pci-assign.c +1
-1@@ -554,7 +554,7 @@ static void get_real_device(AssignedDevice *pci_dev, Error **errp)if (pci_dev->configfd_name && *pci_dev->configfd_name) { dev->config_fd =monitor_fd_param (cur_mon, pci_dev->configfd_name, &local_err); -if (local_err) { +if (dev->config_fd <0 ) {error_propagate (errp, local_err);return ; }
This fix the coverity warning of dev->config_id. I'm not sure that this may introduce another warning of not checking local_err.
Signature · 2 lines
Thanks, Shannon