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

[libvirt] [PATCH] esx_vmx.c: don't dereference a NULL virtualDev



The offending code starts here:

int
esxVMX_ParseSCSIController(virConnectPtr conn, virConfPtr conf, int controller,
                           int *present, char **virtualDev)
{
    char present_name[32];
    char virtualDev_name[32];

    if (virtualDev == NULL || *virtualDev != NULL) {
        ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument");
        goto failure;
    }

If the virtualDev parameter is NULL, then we'd issue the
diagnostic and take the "goto", and (below), dereference NULL.

>From 79283ba1d667534175d4c48079e6b500feba6480 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Tue, 15 Dec 2009 16:07:10 +0100
Subject: [PATCH] esx_vmx.c: don't dereference NULL for a NULL virtualDev

* src/esx/esx_vmx.c (esxVMX_ParseSCSIController): Don't deref
"virtualDev" when it is NULL.
---
 src/esx/esx_vmx.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index f5b4544..404617e 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -1204,7 +1204,8 @@ esxVMX_ParseSCSIController(virConnectPtr conn, virConfPtr conf, int controller,
     return 0;

   failure:
-    VIR_FREE(*virtualDev);
+    if (virtualDev)
+        VIR_FREE(*virtualDev);

     return -1;
 }
--
1.6.6.rc2.275.g51e2d


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