OSDN Git Service

tee: amdtee: skip tee_device_unregister if tee_device_alloc fails
authorRijo Thomas <Rijo-john.Thomas@amd.com>
Thu, 9 Jan 2020 12:53:20 +0000 (18:23 +0530)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 16 Jan 2020 07:18:13 +0000 (15:18 +0800)
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>
drivers/tee/amdtee/core.c

index 0840be0..c657b97 100644 (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);