@@ -420,12 +420,12 @@ static int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id, const uuid_
420
420
rc = tee_client_open_session (ctx , & sess_arg , NULL );
421
421
if (rc < 0 || sess_arg .ret != 0 ) {
422
422
pr_err ("Failed to open TEE session err:%#x, rc:%d\n" , sess_arg .ret , rc );
423
- return rc ;
423
+ return rc ?: - EINVAL ;
424
424
}
425
425
426
426
* id = sess_arg .session ;
427
427
428
- return rc ;
428
+ return 0 ;
429
429
}
430
430
431
431
static 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)
460
460
dev -> tee_ctx = tee_client_open_context (NULL , amd_pmf_amdtee_ta_match , NULL , NULL );
461
461
if (IS_ERR (dev -> tee_ctx )) {
462
462
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 ;
464
466
}
465
467
466
468
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)
500
502
501
503
static void amd_pmf_tee_deinit (struct amd_pmf_dev * dev )
502
504
{
505
+ if (!dev -> tee_ctx )
506
+ return ;
503
507
tee_shm_free (dev -> fw_shm_pool );
504
508
tee_client_close_session (dev -> tee_ctx , dev -> session_id );
505
509
tee_client_close_context (dev -> tee_ctx );
510
+ dev -> tee_ctx = NULL ;
506
511
}
507
512
508
513
int amd_pmf_init_smart_pc (struct amd_pmf_dev * dev )
0 commit comments