From patchwork Thu Mar 29 10:53:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tal Gilboa X-Patchwork-Id: 892704 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40BhSt3DjTz9s0m for ; Thu, 29 Mar 2018 21:54:06 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752370AbeC2KyE (ORCPT ); Thu, 29 Mar 2018 06:54:04 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:34759 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752338AbeC2KyD (ORCPT ); Thu, 29 Mar 2018 06:54:03 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from talgi@mellanox.com) with ESMTPS (AES256-SHA encrypted); 29 Mar 2018 12:54:54 +0200 Received: from gen-l-vrt-692.mtl.labs.mlnx (gen-l-vrt-692.mtl.labs.mlnx [10.141.69.20]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w2TArxqV020438; Thu, 29 Mar 2018 13:53:59 +0300 Received: from gen-l-vrt-692.mtl.labs.mlnx (localhost [127.0.0.1]) by gen-l-vrt-692.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id w2TArxTw018456; Thu, 29 Mar 2018 13:53:59 +0300 Received: (from talgi@localhost) by gen-l-vrt-692.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id w2TArsvY018452; Thu, 29 Mar 2018 13:53:54 +0300 From: Tal Gilboa To: "David S. Miller" Cc: netdev@vger.kernel.org, Tariq Toukan , Tal Gilboa , Andy Gospodarek , Saeed Mahameed Subject: [PATCH net] net/dim: Fix int overflow Date: Thu, 29 Mar 2018 13:53:52 +0300 Message-Id: <1522320832-18416-1-git-send-email-talgi@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When calculating difference between samples, the values are multiplied by 100. Large values may cause int overflow when multiplied (usually on first iteration). Fixed by forcing 100 to be of type unsigned long. Fixes: 4c4dbb4a7363 ("net/mlx5e: Move dynamic interrupt coalescing code to include/linux") Signed-off-by: Tal Gilboa Reviewed-by: Andy Gospodarek --- include/linux/net_dim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/net_dim.h b/include/linux/net_dim.h index bebeaad..29ed8fd 100644 --- a/include/linux/net_dim.h +++ b/include/linux/net_dim.h @@ -231,7 +231,7 @@ static inline void net_dim_exit_parking(struct net_dim *dim) } #define IS_SIGNIFICANT_DIFF(val, ref) \ - (((100 * abs((val) - (ref))) / (ref)) > 10) /* more than 10% difference */ + (((100UL * abs((val) - (ref))) / (ref)) > 10) /* more than 10% difference */ static inline int net_dim_stats_compare(struct net_dim_stats *curr, struct net_dim_stats *prev)