From patchwork Tue Jun 10 00:40:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 357649 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 E3262140077 for ; Tue, 10 Jun 2014 10:40:29 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934327AbaFJAkZ (ORCPT ); Mon, 9 Jun 2014 20:40:25 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:5278 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933996AbaFJAkW (ORCPT ); Mon, 9 Jun 2014 20:40:22 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie2.idc.renesas.com with ESMTP; 10 Jun 2014 09:40:20 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 0C7FA46410; Tue, 10 Jun 2014 09:40:21 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id EC4CC480A7; Tue, 10 Jun 2014 09:40:20 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id E7615480A6; Tue, 10 Jun 2014 09:40:20 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac4.idc.renesas.com with ESMTP id KAD25013; Tue, 10 Jun 2014 09:40:20 +0900 X-IronPort-AV: E=Sophos;i="4.98,1005,1392130800"; d="scan'208";a="162752652" Received: from mail-hk1lp0121.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.121]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES128-SHA; 10 Jun 2014 09:40:20 +0900 Received: from [10.161.20.55] (211.11.155.147) by HKNPR06MB321.apcprd06.prod.outlook.com (10.141.38.15) with Microsoft SMTP Server (TLS) id 15.0.959.24; Tue, 10 Jun 2014 00:40:19 +0000 Message-ID: <539653EE.1000700@renesas.com> Date: Tue, 10 Jun 2014 09:40:14 +0900 From: Yoshihiro Shimoda User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "netdev@vger.kernel.org" CC: SH-Linux , Sergei Shtylyov Subject: [PATCH v2 1/2] net: sh_eth: Fix receive packet "exceeded" condition in sh_eth_rx() X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: SINPR04CA004.apcprd04.prod.outlook.com (10.242.48.34) To HKNPR06MB321.apcprd06.prod.outlook.com (10.141.38.15) X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 0238AEEDB0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(6009001)(6049001)(428001)(199002)(189002)(4396001)(66066001)(81542001)(64126003)(46102001)(87976001)(42186004)(76482001)(21056001)(50466002)(102836001)(81342001)(65956001)(47776003)(77982001)(20776003)(31966008)(101416001)(92726001)(36756003)(74502001)(99396002)(99136001)(54356999)(50986999)(64706001)(92566001)(65816999)(65806001)(79102001)(80022001)(83506001)(83072002)(86362001)(74662001)(87266999)(33656002)(83322001)(19580405001)(19580395003)(85852003)(23756003)(59896001); DIR:OUT; SFP:; SCL:1; SRVR:HKNPR06MB321; H:[10.161.20.55]; FPR:; MLV:sfv; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yoshihiro.shimoda.uh@renesas.com; X-OriginatorOrg: renesas.com Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch fixes the packet "exceeded" condition in sh_eth_rx() when RACT in an RX descriptor is not set and the "quota" is 0. Otherwise, kernel panic happens because the "&n->poll_list" is deleted twice in sh_eth_poll() which calls napi_complete() and net_rx_action(). Signed-off-by: Kouei Abe Signed-off-by: Yoshihiro Shimoda --- drivers/net/ethernet/renesas/sh_eth.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 08ed9a3..5761f8c 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1399,7 +1399,6 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) int entry = mdp->cur_rx % mdp->num_rx_ring; int boguscnt = (mdp->dirty_rx + mdp->num_rx_ring) - mdp->cur_rx; struct sk_buff *skb; - int exceeded = 0; u16 pkt_len = 0; u32 desc_status; @@ -1411,10 +1410,9 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) if (--boguscnt < 0) break; - if (*quota <= 0) { - exceeded = 1; + if (*quota <= 0) break; - } + (*quota)--; if (!(desc_status & RDFEND)) @@ -1508,7 +1506,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) sh_eth_write(ndev, EDRRR_R, EDRRR); } - return exceeded; + return *quota <= 0; } static void sh_eth_rcv_snd_disable(struct net_device *ndev)