diff mbox series

[v8,3/6] tee: fix put order in teedev_close_context()

Message ID 20211103090255.998070-4-jens.wiklander@linaro.org
State Accepted
Commit f18397ab3ae23e8e43bba9986e66af6d4497f2ad
Headers show
Series Asynchronous notifications from secure world | expand

Commit Message

Jens Wiklander Nov. 3, 2021, 9:02 a.m. UTC
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>
 drivers/tee/tee_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff mbox series


diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
index 2b37bc408fc3..85102d12d716 100644
--- a/drivers/tee/tee_core.c
+++ b/drivers/tee/tee_core.c
@@ -98,8 +98,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;
+	tee_device_put(teedev);
 static int tee_open(struct inode *inode, struct file *filp)