提交 762cf6da 编写于 作者: A Arnd Bergmann 提交者: Paul Mackerras

[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: NArnd Bergmann <arndb@de.ibm.com>
Signed-off-by: NPaul Mackerras <paulus@samba.org>
上级 c902be71
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册