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

login
register
mail settings
Submitter Gleb Natapov
Date Sept. 1, 2013, 12:53 p.m.
Message ID <20130901125346.GK22899@redhat.com>
Download mbox | patch
Permalink /patch/271590/
State New
Headers show

Comments

Gleb Natapov - Sept. 1, 2013, 12:53 p.m.
XICS failed to free xics structure on error path. MPIC destroy handler
forgot to delete kvm_device structure.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 Be warned that this is not even compiled tested.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Graf - Sept. 4, 2013, 10:49 a.m.
On 01.09.2013, at 14:53, Gleb Natapov wrote:

> XICS failed to free xics structure on error path. MPIC destroy handler
> forgot to delete kvm_device structure.
> 
> Signed-off-by: Gleb Natapov <gleb@redhat.com>

Paul, please ack :).


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paul Mackerras - Sept. 4, 2013, 12:16 p.m.
On Sun, Sep 01, 2013 at 03:53:46PM +0300, Gleb Natapov wrote:
> XICS failed to free xics structure on error path. MPIC destroy handler
> forgot to delete kvm_device structure.
> 
> Signed-off-by: Gleb Natapov <gleb@redhat.com>

Acked-by: Paul Mackerras <paulus@samba.org>
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Graf - Dec. 9, 2013, 3:16 p.m.
On 04.09.2013, at 14:16, Paul Mackerras <paulus@samba.org> wrote:

> On Sun, Sep 01, 2013 at 03:53:46PM +0300, Gleb Natapov wrote:
>> XICS failed to free xics structure on error path. MPIC destroy handler
>> forgot to delete kvm_device structure.
>> 
>> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> 
> Acked-by: Paul Mackerras <paulus@samba.org>

Thanks, applied to kvm-ppc-queue.


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/powerpc/kvm/book3s_xics.c b/arch/powerpc/kvm/book3s_xics.c
index 94c1dd4..97adfe8 100644
--- a/arch/powerpc/kvm/book3s_xics.c
+++ b/arch/powerpc/kvm/book3s_xics.c
@@ -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);
 
diff --git a/arch/powerpc/kvm/mpic.c b/arch/powerpc/kvm/mpic.c
index 2861ae9..efbd996 100644
--- a/arch/powerpc/kvm/mpic.c
+++ b/arch/powerpc/kvm/mpic.c
@@ -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)