summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2006-01-04 20:31:21 +0100
committerPaul Mackerras <paulus@samba.org>2006-01-09 15:44:35 +1100
commit762cf6dac2623473e83bb271f2bbe97d2355c64d (patch)
tree51871b65240062fc9442965923f710f0782b4e34 /arch
parentc902be71dc6d5e8473bd021feafc8c3608e2b82a (diff)
downloadlinux-762cf6dac2623473e83bb271f2bbe97d2355c64d.tar.bz2
[PATCH] spufs: fix locking in spu_acquire_runnable
We need to check for validity of owner under down_write, down_read is not enough. Noticed by Al Viro. Signed-off-by: Arnd Bergmann <arndb@de.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/platforms/cell/spufs/context.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index 1758cec58bc7..903c35d19577 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -120,27 +120,29 @@ int spu_acquire_runnable(struct spu_context *ctx)
ctx->spu->prio = current->prio;
return 0;
}
+ up_read(&ctx->state_sema);
+
+ down_write(&ctx->state_sema);
/* ctx is about to be freed, can't acquire any more */
if (!ctx->owner) {
ret = -EINVAL;
goto out;
}
- up_read(&ctx->state_sema);
- down_write(&ctx->state_sema);
if (ctx->state == SPU_STATE_SAVED) {
ret = spu_activate(ctx, 0);
ctx->state = SPU_STATE_RUNNABLE;
}
- downgrade_write(&ctx->state_sema);
if (ret)
goto out;
+ downgrade_write(&ctx->state_sema);
/* On success, we return holding the lock */
+
return ret;
out:
/* Release here, to simplify calling code. */
- up_read(&ctx->state_sema);
+ up_write(&ctx->state_sema);
return ret;
}