diff mbox

(no subject)

Message ID 200812101903.mBAJ3chG022791@d24av02.br.ibm.com
State Superseded
Headers show

Commit Message

Andre Detsch Dec. 10, 2008, 7:03 p.m. UTC
From 3b992bb08fb4a5506446a2347fa0f28170c0a60c Mon Sep 17 00:00:00 2001
In-Reply-To: <200812101654.05091.adetsch@br.ibm.com>
References: <200812101654.05091.adetsch@br.ibm.com>
From: Andre Detsch <adetsch@br.ibm.com>
Date: Wed, 10 Dec 2008 17:03:39 -0200
Subject: [PATCH 13/18] powerpc/spufs: Fix memory leak on implicit gangs
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200812101703.39179.adetsch@br.ibm.com>

If the context has no explicit gang, there is no spufs gang
directory, whose deletion would lead to a put_spu_context.
So, we need to perform a put_spu_context operation after
the context was allocated, or else the gang would never be
freeded.

Signed-off-by: Andre Detsch <adetsch@br.ibm.com>
---
 arch/powerpc/platforms/cell/spufs/context.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

 	/* Binding to physical processor deferred
@@ -107,6 +111,15 @@ struct spu_context *alloc_spu_context(struct spu_gang 
*gang)
 
 	atomic_inc(&nr_spu_contexts);
 
+	/*
+	 * If the context has no explicit gang, there is no spufs gang
+	 * directory, whose deletion would lead to a put_spu_context.
+	 * So, we do the put here, or else the gang would never be
+	 * freeded.
+	 */
+	if (!has_gang)
+		put_spu_gang(gang);
+
 	goto out;
 
 out_free_gang:
diff mbox

Patch

diff --git a/arch/powerpc/platforms/cell/spufs/context.c 
b/arch/powerpc/platforms/cell/spufs/context.c
index 3bda369..0e37eff 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -51,6 +51,7 @@  static void dec_active_gangs(struct spu_gang *gang)
 struct spu_context *alloc_spu_context(struct spu_gang *gang)
 {
 	struct spu_context *ctx;
+	int has_gang;
 
 	ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
 	if (!ctx)
@@ -62,9 +63,12 @@  struct spu_context *alloc_spu_context(struct spu_gang 
*gang)
 	 * the gang is a gang of one.
 	 */
 	if (!gang) {
+		has_gang = 0;
 		gang = alloc_spu_gang();
 		if (!gang)
 			goto out_free;
+	} else {
+		has_gang = 1;
 	}