Commit 29290155 authored by Rijo Thomas's avatar Rijo Thomas Committed by Herbert Xu
Browse files

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarRijo Thomas <Rijo-john.Thomas@amd.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent f4c58c37
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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);