crypto: tegra-se: Check for valid reqeusted buffer size
Mallikarjun Kasoju [Mon, 12 Mar 2012 03:51:25 +0000 (08:51 +0530)]
Added check for valid requested process buffer size.

Bug 928454

Change-Id: I2dc389af64cb3de2f0a0a3f0bbc5057dd9bd676c
Reviewed-on: http://git-master/r/89381
Reviewed-by: Mallikarjun Kasoju <mkasoju@nvidia.com>
Tested-by: Mallikarjun Kasoju <mkasoju@nvidia.com>
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>

Rebase-Id: R9fd50e7dc33a4e85e6bf2080ffea1a55edd15172

drivers/crypto/tegra-se.c

index 4dde931..3d2e918 100644 (file)
@@ -846,6 +846,9 @@ static int tegra_se_aes_queue_req(struct ablkcipher_request *req)
        bool idle = true;
        int err = 0;
 
+       if (!req->nbytes)
+               return -EINVAL;
+
        spin_lock_irqsave(&se_dev->lock, flags);
        err = ablkcipher_enqueue_request(&se_dev->queue, req);
        if (se_dev->work_q_busy)
@@ -1203,6 +1206,9 @@ int tegra_se_sha_final(struct ahash_request *req)
        u32 total, num_sgs;
        int err = 0;
 
+       if (!req->nbytes)
+               return -EINVAL;
+
        if (crypto_ahash_digestsize(tfm) == SHA1_DIGEST_SIZE)
                sha_ctx->op_mode = SE_AES_OP_MODE_SHA1;