[PATCH v2] linux/dim: Fix divide 0 in RDMA DIM.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We hit a divide 0 error in ofed 5.1.2.3.7.1. It is caused in
rdma_dim_stats_compare() when prev->cpe_ratio == 0.

dim.c and rdma_dim.c in ofed share same code with upstream.
We check the 0 case in IS_SIGNIFICANT_DIFF(), and do not change
decision order.

Signed-off-by: Tao Liu <thomas.liu@xxxxxxxxx>
---
 include/linux/dim.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/dim.h b/include/linux/dim.h
index b698266d0035..6c5733981563 100644
--- a/include/linux/dim.h
+++ b/include/linux/dim.h
@@ -21,7 +21,7 @@
  * We consider 10% difference as significant.
  */
 #define IS_SIGNIFICANT_DIFF(val, ref) \
-	(((100UL * abs((val) - (ref))) / (ref)) > 10)
+	((ref) && (((100UL * abs((val) - (ref))) / (ref)) > 10))
 
 /*
  * Calculate the gap between two values.
-- 
2.30.1 (Apple Git-130)




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux