From: Rijo Thomas Date: Thu, 9 Jan 2020 12:53:20 +0000 (+0530) Subject: tee: amdtee: skip tee_device_unregister if tee_device_alloc fails X-Git-Tag: block-5.6-2020-02-05~44^2~39 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=2929015535fa355f604564ae5e542fd3c9179410;p=linux-block.git 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 Signed-off-by: Rijo Thomas Signed-off-by: Herbert Xu --- diff --git a/drivers/tee/amdtee/core.c b/drivers/tee/amdtee/core.c index 0840be03a3ab..c657b9728eae 100644 --- a/drivers/tee/amdtee/core.c +++ b/drivers/tee/amdtee/core.c @@ -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);