@@ -420,12 +420,12 @@ static int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id, const uuid_
420420 rc = tee_client_open_session (ctx , & sess_arg , NULL );
421421 if (rc < 0 || sess_arg .ret != 0 ) {
422422 pr_err ("Failed to open TEE session err:%#x, rc:%d\n" , sess_arg .ret , rc );
423- return rc ;
423+ return rc ?: - EINVAL ;
424424 }
425425
426426 * id = sess_arg .session ;
427427
428- return rc ;
428+ return 0 ;
429429}
430430
431431static int amd_pmf_register_input_device (struct amd_pmf_dev * dev )
@@ -460,7 +460,9 @@ static int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid)
460460 dev -> tee_ctx = tee_client_open_context (NULL , amd_pmf_amdtee_ta_match , NULL , NULL );
461461 if (IS_ERR (dev -> tee_ctx )) {
462462 dev_err (dev -> dev , "Failed to open TEE context\n" );
463- return PTR_ERR (dev -> tee_ctx );
463+ ret = PTR_ERR (dev -> tee_ctx );
464+ dev -> tee_ctx = NULL ;
465+ return ret ;
464466 }
465467
466468 ret = amd_pmf_ta_open_session (dev -> tee_ctx , & dev -> session_id , uuid );
@@ -500,9 +502,12 @@ static int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid)
500502
501503static void amd_pmf_tee_deinit (struct amd_pmf_dev * dev )
502504{
505+ if (!dev -> tee_ctx )
506+ return ;
503507 tee_shm_free (dev -> fw_shm_pool );
504508 tee_client_close_session (dev -> tee_ctx , dev -> session_id );
505509 tee_client_close_context (dev -> tee_ctx );
510+ dev -> tee_ctx = NULL ;
506511}
507512
508513int amd_pmf_init_smart_pc (struct amd_pmf_dev * dev )
0 commit comments