misc: tegra-cryptodev: fix resource leak
Sri Krishna chowdary [Mon, 29 Oct 2012 11:53:27 +0000 (16:53 +0530)]
Memory allocated from ablkcipher_request_alloc is
not deallocated before function returns when
crypt_req->keylen is invalid.

Bug 1046331

Change-Id: I9d74159c0653b5b5d08e3d0d00b1919590d7599f
Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com>
Reviewed-on: http://git-master/r/159533
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Varun Wadekar <vwadekar@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

drivers/misc/tegra-cryptodev.c

index eab62a9..0d4a089 100644 (file)
@@ -239,8 +239,11 @@ static int process_crypt_req(struct tegra_crypto_ctx *ctx, struct tegra_crypt_re
                return -ENOMEM;
        }
 
-       if ((crypt_req->keylen < 0) || (crypt_req->keylen > AES_MAX_KEY_SIZE))
-               return -EINVAL;
+       if ((crypt_req->keylen < 0) || (crypt_req->keylen > AES_MAX_KEY_SIZE)) {
+               ret = -EINVAL;
+               pr_err("crypt_req keylen invalid");
+               goto process_req_out;
+       }
 
        crypto_ablkcipher_clear_flags(tfm, ~0);