summaryrefslogtreecommitdiff
path: root/drivers/tee
diff options
context:
space:
mode:
authorJens Wiklander <jens.wiklander@linaro.org>2021-06-15 23:23:50 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-01-27 11:19:30 +0300
commitda0b42d1c3fb95011aaa2e34fa3822e17ba23c1c (patch)
tree2634046305dc831ddbb264833b6671e7a991ff66 /drivers/tee
parent24161b9c43de966789d5956428f45002d10f878e (diff)
downloadlinux-da0b42d1c3fb95011aaa2e34fa3822e17ba23c1c.tar.xz
tee: fix put order in teedev_close_context()
[ Upstream commit f18397ab3ae23e8e43bba9986e66af6d4497f2ad ] Prior to this patch was teedev_close_context() calling tee_device_put() before teedev_ctx_put() leading to teedev_ctx_release() accessing ctx->teedev just after the reference counter was decreased on the teedev. Fix this by calling teedev_ctx_put() before tee_device_put(). Fixes: 217e0250cccb ("tee: use reference counting for tee_context") Reviewed-by: Sumit Garg <sumit.garg@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/tee')
-rw-r--r--drivers/tee/tee_core.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
index 0f16d9ffd8d1..85e0cef9e917 100644
--- a/drivers/tee/tee_core.c
+++ b/drivers/tee/tee_core.c
@@ -84,8 +84,10 @@ void teedev_ctx_put(struct tee_context *ctx)
static void teedev_close_context(struct tee_context *ctx)
{
- tee_device_put(ctx->teedev);
+ struct tee_device *teedev = ctx->teedev;
+
teedev_ctx_put(ctx);
+ tee_device_put(teedev);
}
static int tee_open(struct inode *inode, struct file *filp)