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 <[email protected]>
Index: linux-cg/arch/powerpc/platforms/cell/spufs/context.c
===================================================================
--- linux-cg.orig/arch/powerpc/platforms/cell/spufs/context.c 2005-12-22 12:10:15.000000000 +0000
+++ linux-cg/arch/powerpc/platforms/cell/spufs/context.c 2005-12-22 12:10:20.000000000 +0000
@@ -120,27 +120,29 @@
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;
}
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]