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

[libvirt] [PATCH 04/10] storage_driver: Resolve Coverity REVERSE_INULL



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 redhat com>
---
 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


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