From bade7e1fbd34f46462e6eb1db5474832a4144ac2 Mon Sep 17 00:00:00 2001 From: Rijo Thomas Date: Fri, 27 Dec 2019 10:54:02 +0530 Subject: tee: amdtee: check TEE status during driver initialization The AMD-TEE driver should check if TEE is available before registering itself with TEE subsystem. This ensures that there is a TEE which the driver can talk to before proceeding with tee device node allocation. Cc: Ard Biesheuvel Cc: Tom Lendacky Acked-by: Jens Wiklander Co-developed-by: Devaraj Rangasamy Signed-off-by: Devaraj Rangasamy Signed-off-by: Rijo Thomas Reviewed-by: Gary R Hook Signed-off-by: Herbert Xu --- drivers/tee/amdtee/core.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/tee') diff --git a/drivers/tee/amdtee/core.c b/drivers/tee/amdtee/core.c index dd360f378ef0..9d0cee1c837f 100644 --- a/drivers/tee/amdtee/core.c +++ b/drivers/tee/amdtee/core.c @@ -16,6 +16,7 @@ #include #include "amdtee_private.h" #include "../tee_private.h" +#include static struct amdtee_driver_data *drv_data; static DEFINE_MUTEX(session_list_mutex); @@ -438,6 +439,10 @@ static int __init amdtee_driver_init(void) struct tee_shm_pool *pool = ERR_PTR(-EINVAL); int rc; + rc = psp_check_tee_status(); + if (rc) + goto err_fail; + drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL); if (IS_ERR(drv_data)) return -ENOMEM; @@ -485,6 +490,7 @@ err_kfree_drv_data: kfree(drv_data); drv_data = NULL; +err_fail: pr_err("amd-tee driver initialization failed\n"); return rc; } -- cgit v1.2.3