[libvirt] [PATCH 17/17] Fix leak of serial value in xenFormatXM on OOM

Daniel P. Berrange berrange at redhat.com
Tue Sep 24 16:04:07 UTC 2013


From: "Daniel P. Berrange" <berrange at redhat.com>

If an OOM occurs in xenFormatXM when formatting to the
serial device value, the value is leaked.

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 src/xenxs/xen_xm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 7550a07..9e07f95 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1959,8 +1959,10 @@ virConfPtr xenFormatXM(virConnectPtr conn,
                             break;
                         }
                     }
-                    if (xenFormatXMSerial(serialVal, chr) < 0)
+                    if (xenFormatXMSerial(serialVal, chr) < 0) {
+                        virConfFreeValue(serialVal);
                         goto cleanup;
+                    }
                 }
 
                 if (serialVal->list != NULL) {
-- 
1.8.3.1




More information about the libvir-list mailing list