tee: fix put order in teedev_close_context()
authorJens Wiklander <jens.wiklander@linaro.org>
Tue, 15 Jun 2021 20:23:50 +0000 (22:23 +0200)
committerJens Wiklander <jens.wiklander@linaro.org>
Wed, 17 Nov 2021 13:08:54 +0000 (14:08 +0100)
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

index 2b37bc408fc3d7a293bde9c849bd625ca1c0b553..85102d12d716997c19862663786cf539d7a37f5a 100644 (file)
@@ -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;
+
        teedev_ctx_put(ctx);
+       tee_device_put(teedev);
 }
 
 static int tee_open(struct inode *inode, struct file *filp)