From patchwork Sat Jul 21 20:30:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ISHIKAWA Mutsumi X-Patchwork-Id: 172455 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2FB632C01CC for ; Sun, 22 Jul 2012 06:39:08 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751938Ab2GUUi0 (ORCPT ); Sat, 21 Jul 2012 16:38:26 -0400 Received: from hanzubin.st.wakwak.ne.jp ([61.115.118.67]:46414 "EHLO master.hanzubon.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751737Ab2GUUiZ (ORCPT ); Sat, 21 Jul 2012 16:38:25 -0400 X-Greylist: delayed 468 seconds by postgrey-1.27 at vger.kernel.org; Sat, 21 Jul 2012 16:38:25 EDT Received: from localhost (localhost [127.0.0.1]) by master.hanzubon.jp (Postfix) with ESMTP id 71B4DFFC4A; Sun, 22 Jul 2012 05:30:35 +0900 (JST) X-Virus-Scanned: Debian amavisd-new at hanzubon.jp Received: from master.hanzubon.jp ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with LMTP id DlaowRYvR2RX; Sun, 22 Jul 2012 05:30:35 +0900 (JST) Received: from pippen.hanzubon.jp (pippen.hanzubon.jp [192.168.100.26]) by master.hanzubon.jp (Postfix) with ESMTP id 545B5FFBCE; Sun, 22 Jul 2012 05:30:35 +0900 (JST) Date: Sun, 22 Jul 2012 05:30:35 +0900 From: ISHIKAWA Mutsumi To: jpirko@redhat.com Cc: netdev@vger.kernel.org Subject: [PATCH] Fix divide zero crash when xmit with no enabled port User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-2022-JP-2?B?R29qGyQoRCtXGyhC?=) APEL/10.8 Emacs/24.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Message-Id: <20120721203035.71B4DFFC4A@master.hanzubon.jp> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org hash calculation in lb_transmit() cause divide zero crash when xmit on teaming loadbalance mode with no team member port is enabled (this situation means team->en_port_count = 0). Add check team->en_port_count is not 0. --- drivers/net/team/team_mode_loadbalance.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/team_mode_loadbalance.c index 86e8183..7b878d5 100644 --- a/drivers/net/team/team_mode_loadbalance.c +++ b/drivers/net/team/team_mode_loadbalance.c @@ -38,6 +38,8 @@ static bool lb_transmit(struct team *team, struct sk_buff *skb) if (unlikely(!fp)) goto drop; hash = SK_RUN_FILTER(fp, skb); + if (team->en_port_count < 1) + goto drop; port_index = hash % team->en_port_count; port = team_get_port_by_index_rcu(team, port_index); if (unlikely(!port))