Skip to contentSkip to conversation

KVM: PPC: fix couple of memory leaks in MPIC/XICS devices

PATCH Applied Gleb Natapov 3 participants 4 messages Sep 1, 2013 – Dec 9, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: PPC: fix couple of memory leaks in MPIC/XICS devices

XICS failed to free xics structure on error path. MPIC destroy handler forgot to delete kvm_device structure.

---
Be warned that this is not even compiled tested.

arch/powerpc/kvm/book3s_xics.c +3 -1
index 94c1dd4..97adfe8 100644
@@ -1244,8 +1244,10 @@ static int kvmppc_xics_create(struct kvm_device *dev, u32 type)
 		kvm->arch.xics = xics;
 	mutex_unlock(&kvm->lock);
 
-	if (ret)
+	if (ret) {
+		kfree(xics);
 		return ret;
+	}
 
 	xics_debugfs_init(xics);
 
arch/powerpc/kvm/mpic.c +1 -0
index 2861ae9..efbd996 100644
@@ -1635,6 +1635,7 @@ static void mpic_destroy(struct kvm_device *dev)
 
 	dev->kvm->arch.mpic = NULL;
 	kfree(opp);
+	kfree(dev);
 }
 
 static int mpic_set_default_irq_routing(struct openpic *opp)

--
Gleb.