From 0c8d53e17be600c99e4a8f96062f39306c3ccad8 Mon Sep 17 00:00:00 2001 From: Gu Zheng Date: Tue, 14 Feb 2017 11:26:11 +0800 Subject: [PATCH] LU-9116 libcfs: avoid overflow of crypto bandwidth caculation bcount and buf_len are both int, and no force convert in the caculation code: tmp = ((bcount * buf_len / jiffies_to_msecs(end - start)) * 1000) / (1024 * 1024); That may cause overflow in modern fast machine. Change-Id: I1e5abccad3e4df62907317a09de02beb6d831e13 Signed-off-by: Gu Zheng Reviewed-on: https://review.whamcloud.com/25436 Reviewed-by: Andreas Dilger Reviewed-by: Emoly Liu Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Li Xi --- libcfs/libcfs/linux/linux-crypto.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcfs/libcfs/linux/linux-crypto.c b/libcfs/libcfs/linux/linux-crypto.c index a8c2ccd..1a0a105 100644 --- a/libcfs/libcfs/linux/linux-crypto.c +++ b/libcfs/libcfs/linux/linux-crypto.c @@ -319,7 +319,8 @@ static void cfs_crypto_performance_test(enum cfs_crypto_hash_alg hash_alg) int buf_len = max(PAGE_SIZE, 1048576UL); void *buf; unsigned long start, end; - int bcount, err = 0; + int err = 0; + unsigned long bcount; struct page *page; unsigned char hash[CFS_CRYPTO_HASH_DIGESTSIZE_MAX]; unsigned int hash_len = sizeof(hash); -- 1.8.3.1