Loading
RDMA/hns: Fix integer overflow in calc_loading_percent()
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IAL7SX ---------------------------------------------------------------------- For calc_loading_percent(), if the values of two types of u32 are multiplied, the result can be an integer overflow. To fix it, convert all variable to u64. Since total and free are both size_t, alloc_pages and free_pages may overflow. In addition, because there is multiplication in the calculation of percent, it may also cause overflow of u32. In this patch all relevant variables are converted to u64. This patch also adds corresponding processing for the exception of calc_loading_percent() to avoid printing a wrong result. Fixes: a2178118 ("RDMA/hns: Add debugfs support for DCA") Signed-off-by:Yuyu Li <liyuyu6@huawei.com> Signed-off-by:
Chengchang Tang <tangchengchang@huawei.com> Signed-off-by:
Xinghai Cen <cenxinghai@h-partners.com>