diff options
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/inode.c | 29 |
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 * | |||
322 | spufs_assert_affinity(unsigned int flags, struct spu_gang *gang, | 322 | spufs_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 | |||
387 | out_put_neighbor: | ||
388 | put_spu_context(neighbor); | ||
389 | return err; | ||
380 | } | 390 | } |
381 | 391 | ||
382 | static void | 392 | static 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 |