aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAndre Detsch <adetsch@br.ibm.com>2008-01-10 23:03:26 -0500
committerPaul Mackerras <paulus@samba.org>2008-02-06 00:26:59 -0500
commit58119068cb27ef7513f80aff44b62a3a8f40ef5f (patch)
tree2ec652c66c008f99aeffc9a271d4398df9de90ce /arch
parent60cf54db47727935af1c439f59c636a96a8cbd4b (diff)
[POWERPC] spufs: Fix memory leak on SPU affinity
Reference count for the "neighbor" spu context was not being correctly decremented after usage. So, contexts used as reference during SPU affinity setup were not being deallocated, leading to a memory leak. Signed-off-by: Andre Detsch <adetsch@br.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index c0e968a4c211..90784c029f25 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -322,7 +322,7 @@ static struct spu_context *
322spufs_assert_affinity(unsigned int flags, struct spu_gang *gang, 322spufs_assert_affinity(unsigned int flags, struct spu_gang *gang,
323 struct file *filp) 323 struct file *filp)
324{ 324{
325 struct spu_context *tmp, *neighbor; 325 struct spu_context *tmp, *neighbor, *err;
326 int count, node; 326 int count, node;
327 int aff_supp; 327 int aff_supp;
328 328
@@ -354,11 +354,15 @@ spufs_assert_affinity(unsigned int flags, struct spu_gang *gang,
354 if (!list_empty(&neighbor->aff_list) && !(neighbor->aff_head) && 354 if (!list_empty(&neighbor->aff_list) && !(neighbor->aff_head) &&
355 !list_is_last(&neighbor->aff_list, &gang->aff_list_head) && 355 !list_is_last(&neighbor->aff_list, &gang->aff_list_head) &&
356 !list_entry(neighbor->aff_list.next, struct spu_context, 356 !list_entry(neighbor->aff_list.next, struct spu_context,
357 aff_list)->aff_head) 357 aff_list)->aff_head) {
358 return ERR_PTR(-EEXIST); 358 err = ERR_PTR(-EEXIST);
359 goto out_put_neighbor;
360 }
359 361
360 if (gang != neighbor->gang) 362 if (gang != neighbor->gang) {
361 return ERR_PTR(-EINVAL); 363 err = ERR_PTR(-EINVAL);
364 goto out_put_neighbor;
365 }
362 366
363 count = 1; 367 count = 1;
364 list_for_each_entry(tmp, &gang->aff_list_head, aff_list) 368 list_for_each_entry(tmp, &gang->aff_list_head, aff_list)
@@ -372,11 +376,17 @@ spufs_assert_affinity(unsigned int flags, struct spu_gang *gang,
372 break; 376 break;
373 } 377 }
374 378
375 if (node == MAX_NUMNODES) 379 if (node == MAX_NUMNODES) {
376 return ERR_PTR(-EEXIST); 380 err = ERR_PTR(-EEXIST);
381 goto out_put_neighbor;
382 }
377 } 383 }
378 384
379 return neighbor; 385 return neighbor;
386
387out_put_neighbor:
388 put_spu_context(neighbor);
389 return err;
380} 390}
381 391
382static void 392static void
@@ -454,9 +464,12 @@ spufs_create_context(struct inode *inode, struct dentry *dentry,
454 if (ret) 464 if (ret)
455 goto out_aff_unlock; 465 goto out_aff_unlock;
456 466
457 if (affinity) 467 if (affinity) {
458 spufs_set_affinity(flags, SPUFS_I(dentry->d_inode)->i_ctx, 468 spufs_set_affinity(flags, SPUFS_I(dentry->d_inode)->i_ctx,
459 neighbor); 469 neighbor);
470 if (neighbor)
471 put_spu_context(neighbor);
472 }
460 473
461 /* 474 /*
462 * get references for dget and mntget, will be released 475 * get references for dget and mntget, will be released