mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
libxl: Fix Coverity warning
John Ferlan reported the following Coverity warning: In libxlDomainCoreDump() Coverity has noted a FORWARD_NULL reference: 2004 if ((flags & VIR_DUMP_CRASH) && !vm->persistent) { 2005 virDomainObjListRemove(driver->domains, vm); (20) Event assign_zero: Assigning: "vm" = "NULL". Also see events: [var_deref_model] 2006 vm = NULL; 2007 } 2008 2009 ret = 0; 2010 2011 cleanup_unpause: (21) Event var_deref_model: Passing null pointer "vm" to function "virDomainObjIsActive(virDomainObjPtr)", which dereferences it. [details] Also see events: [assign_zero] 2012 if (virDomainObjIsActive(vm) && paused) { 2013 if (libxl_domain_unpause(priv->ctx, dom->id) != 0) { 2014 virReportError(VIR_ERR_INTERNAL_ERROR, Removing the vm from domain obj list and setting it to NULL can be done in the previous 'if (flags & VIR_DUMP_CRASH)' conditional. Fix the Coverity warning by ensuring vm is not NULL before testing if it is still active.
This commit is contained in:
parent
c021f5cecc
commit
5236aed83f
@ -1999,17 +1999,16 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
|
||||
|
||||
event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
|
||||
VIR_DOMAIN_EVENT_STOPPED_CRASHED);
|
||||
}
|
||||
|
||||
if ((flags & VIR_DUMP_CRASH) && !vm->persistent) {
|
||||
virDomainObjListRemove(driver->domains, vm);
|
||||
vm = NULL;
|
||||
if (!vm->persistent) {
|
||||
virDomainObjListRemove(driver->domains, vm);
|
||||
vm = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup_unpause:
|
||||
if (virDomainObjIsActive(vm) && paused) {
|
||||
if (vm && virDomainObjIsActive(vm) && paused) {
|
||||
if (libxl_domain_unpause(priv->ctx, dom->id) != 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("After dumping core, failed to resume domain '%d' with"
|
||||
|
Loading…
Reference in New Issue
Block a user