thermal: intel: int340x: Protect trip temperature from concurrent updates
[platform/kernel/linux-rpi.git] / drivers / tee / tee_core.c
index 2b37bc4..a44e5b5 100644 (file)
@@ -43,7 +43,7 @@ static DEFINE_SPINLOCK(driver_lock);
 static struct class *tee_class;
 static dev_t tee_devt;
 
-static struct tee_context *teedev_open(struct tee_device *teedev)
+struct tee_context *teedev_open(struct tee_device *teedev)
 {
        int rc;
        struct tee_context *ctx;
@@ -70,6 +70,7 @@ err:
        return ERR_PTR(rc);
 
 }
+EXPORT_SYMBOL_GPL(teedev_open);
 
 void teedev_ctx_get(struct tee_context *ctx)
 {
@@ -96,11 +97,14 @@ void teedev_ctx_put(struct tee_context *ctx)
        kref_put(&ctx->refcount, teedev_ctx_release);
 }
 
-static void teedev_close_context(struct tee_context *ctx)
+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);
 }
+EXPORT_SYMBOL_GPL(teedev_close_context);
 
 static int tee_open(struct inode *inode, struct file *filp)
 {
@@ -330,6 +334,9 @@ tee_ioctl_shm_register(struct tee_context *ctx,
        if (data.flags)
                return -EINVAL;
 
+       if (!access_ok((void __user *)(unsigned long)data.addr, data.length))
+               return -EFAULT;
+
        shm = tee_shm_register(ctx, data.addr, data.length,
                               TEE_SHM_DMA_BUF | TEE_SHM_USER_MAPPED);
        if (IS_ERR(shm))