[PATCH 04/10] storage_driver: Resolve Coverity REVERSE_INULL

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

 



There were two occurrances of attempting to initialize actualType by
calling virStorageSourceGetActualType(src) prior to a check if (!src)
resulting in Coverity complaining about the possible NULL dereference
in virStorageSourceGetActualType() of src.

Resolve by moving the actualType setting until after checking !src

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_driver.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 5ddc23a..433d7b7 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -2441,11 +2441,12 @@ virStorageFileIsInitialized(virStorageSourcePtr src)
 static bool
 virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src)
 {
-    int actualType = virStorageSourceGetActualType(src);
+    int actualType;
     virStorageFileBackendPtr backend;
 
     if (!src)
         return false;
+    actualType = virStorageSourceGetActualType(src);
 
     if (src->drv) {
         backend = src->drv->backend;
@@ -2473,11 +2474,12 @@ virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src)
 bool
 virStorageFileSupportsSecurityDriver(virStorageSourcePtr src)
 {
-    int actualType = virStorageSourceGetActualType(src);
+    int actualType;
     virStorageFileBackendPtr backend;
 
     if (!src)
         return false;
+    actualType = virStorageSourceGetActualType(src);
 
     if (src->drv) {
         backend = src->drv->backend;
-- 
1.9.3

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]