platform/x86/amd: pmf: Prevent amd_pmf_tee_deinit() from running twice
[ Upstream commit 93103d56650d7a38ed37ba4041578310f82776ae ]
If any of the tee init fails, pass up the errors and clear the tee_ctx
pointer. This will prevent cleaning up multiple times.
Fixes: ac052d8c08 ("platform/x86/amd/pmf: Add PMF TEE interface")
Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20250512211154.2510397-3-superm1@kernel.org
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20250522003457.1516679-3-superm1@kernel.org
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c4972e7723
commit
78f8e25442
@@ -422,12 +422,12 @@ static int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id, const uuid_
|
||||
rc = tee_client_open_session(ctx, &sess_arg, NULL);
|
||||
if (rc < 0 || sess_arg.ret != 0) {
|
||||
pr_err("Failed to open TEE session err:%#x, rc:%d\n", sess_arg.ret, rc);
|
||||
return rc;
|
||||
return rc ?: -EINVAL;
|
||||
}
|
||||
|
||||
*id = sess_arg.session;
|
||||
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int amd_pmf_register_input_device(struct amd_pmf_dev *dev)
|
||||
@@ -462,7 +462,9 @@ static int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid)
|
||||
dev->tee_ctx = tee_client_open_context(NULL, amd_pmf_amdtee_ta_match, NULL, NULL);
|
||||
if (IS_ERR(dev->tee_ctx)) {
|
||||
dev_err(dev->dev, "Failed to open TEE context\n");
|
||||
return PTR_ERR(dev->tee_ctx);
|
||||
ret = PTR_ERR(dev->tee_ctx);
|
||||
dev->tee_ctx = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = amd_pmf_ta_open_session(dev->tee_ctx, &dev->session_id, uuid);
|
||||
@@ -502,9 +504,12 @@ out_ctx:
|
||||
|
||||
static void amd_pmf_tee_deinit(struct amd_pmf_dev *dev)
|
||||
{
|
||||
if (!dev->tee_ctx)
|
||||
return;
|
||||
tee_shm_free(dev->fw_shm_pool);
|
||||
tee_client_close_session(dev->tee_ctx, dev->session_id);
|
||||
tee_client_close_context(dev->tee_ctx);
|
||||
dev->tee_ctx = NULL;
|
||||
}
|
||||
|
||||
int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
|
||||
|
||||
Reference in New Issue
Block a user