tee: amdtee: skip tee_device_unregister if tee_device_alloc fails

Currently, if tee_device_alloc() fails, then tee_device_unregister()
is a no-op. Therefore, skip the function call to tee_device_unregister() by
introducing a new goto label 'err_free_pool'.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rijo Thomas <Rijo-john.Thomas@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Rijo Thomas 2020-01-09 18:23:20 +05:30 committed by Herbert Xu
parent f4c58c3758
commit 2929015535

View File

@ -465,7 +465,7 @@ static int __init amdtee_driver_init(void)
teedev = tee_device_alloc(&amdtee_desc, NULL, pool, amdtee);
if (IS_ERR(teedev)) {
rc = PTR_ERR(teedev);
goto err;
goto err_free_pool;
}
amdtee->teedev = teedev;
@ -482,6 +482,8 @@ static int __init amdtee_driver_init(void)
err:
tee_device_unregister(amdtee->teedev);
err_free_pool:
if (pool)
tee_shm_pool_free(pool);