diff options
author | Mallikarjun Kasoju <mkasoju@nvidia.com> | 2012-01-17 19:52:05 +0530 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2012-01-19 16:26:46 -0800 |
commit | 58f2a48aba86b1ea804f9b11514d5545dde5a153 (patch) | |
tree | d79c95adf63e826f31edb4f1ea9d310dfa5004a0 /drivers/crypto | |
parent | f245f8f8bd58d1df0a1eb1bf73ad03fb3772813d (diff) |
crypto: tegra-se: Fix SG buffer length mismatch
Fixed the case where SG buffer length is more than actual number
of bytes to process.
Bug 922857
Change-Id: I8445d8ae74b8fc6c964c19523fcd731f7ba4bd37
Reviewed-on: http://git-master/r/75701
Signed-off-by: Mallikarjun Kasoju <mkasoju@nvidia.com>
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Reviewed-on: http://git-master/r/75891
Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/tegra-se.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/crypto/tegra-se.c b/drivers/crypto/tegra-se.c index 60ad2198461d..4dde9310d512 100644 --- a/drivers/crypto/tegra-se.c +++ b/drivers/crypto/tegra-se.c @@ -622,9 +622,9 @@ static int tegra_se_count_sgs(struct scatterlist *sl, u32 total_bytes) return 0; do { - total_bytes -= sl[i].length; + total_bytes -= min(sl[i].length, total_bytes); i++; - } while (total_bytes > 0); + } while (total_bytes); return i; } @@ -723,11 +723,11 @@ static int tegra_se_setup_ablk_req(struct tegra_se_dev *se_dev, WARN_ON(src_sg->length != dst_sg->length); src_ll->addr = sg_dma_address(src_sg); - src_ll->data_len = src_sg->length; + src_ll->data_len = min(src_sg->length, total); dst_ll->addr = sg_dma_address(dst_sg); - dst_ll->data_len = dst_sg->length; + dst_ll->data_len = min(dst_sg->length, total); + total -= min(src_sg->length, total); - total -= src_sg->length; src_sg = sg_next(src_sg); dst_sg = sg_next(dst_sg); dst_ll++; @@ -750,7 +750,7 @@ static void tegra_se_dequeue_complete_req(struct tegra_se_dev *se_dev, while (total) { dma_unmap_sg(se_dev->dev, dst_sg, 1, DMA_FROM_DEVICE); dma_unmap_sg(se_dev->dev, src_sg, 1, DMA_TO_DEVICE); - total -= src_sg->length; + total -= min(src_sg->length, total); src_sg = sg_next(src_sg); dst_sg = sg_next(dst_sg); } |