[libvirt] [PATCH 1/6] virNetDevBridgeGet: Avoid NULL dereference

Michal Privoznik mprivozn at redhat.com
Tue May 31 10:33:25 UTC 2016


It may happen, that this function would dereference a NULL
pointer:

util/virnetdevbridge.c: In function 'virNetDevBridgeGetVlanFiltering':
util/virnetdevbridge.c:199:23: error: null pointer dereference [-Werror=null-dereference]
         ifr->ifr_data = (char*)&args;
         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/util/virnetdevbridge.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index ef1f4cc..f694863 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -193,7 +193,7 @@ static int virNetDevBridgeGet(const char *brname,
             goto cleanup;
         }
         VIR_FREE(valuestr);
-    } else {
+    } else if (ifr) {
         struct __bridge_info info;
         unsigned long args[] = { BRCTL_GET_BRIDGE_INFO, (unsigned long)&info, 0, 0 };
         ifr->ifr_data = (char*)&args;
@@ -212,6 +212,10 @@ static int virNetDevBridgeGet(const char *brname,
                                  _("Unable to get bridge %s %s"), brname, paramname);
             goto cleanup;
         }
+    } else {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Unable to get bridge %s %s"), brname, paramname);
+        goto cleanup;
     }
 
     ret = 0;
-- 
2.8.3




More information about the libvir-list mailing list