From patchwork Mon Jun 9 10:39:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 357403 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 84BBC140076 for ; Mon, 9 Jun 2014 20:39:30 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754725AbaFIKjY (ORCPT ); Mon, 9 Jun 2014 06:39:24 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:18096 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754042AbaFIKjX (ORCPT ); Mon, 9 Jun 2014 06:39:23 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 09 Jun 2014 19:39:22 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 622E241CC9; Mon, 9 Jun 2014 19:39:22 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 50C2380195; Mon, 9 Jun 2014 19:39:22 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 4A96A80193; Mon, 9 Jun 2014 19:39:22 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id VBB14799; Mon, 9 Jun 2014 19:39:22 +0900 X-IronPort-AV: E=Sophos;i="4.98,1001,1392130800"; d="scan'208";a="161655583" Received: from mail-hk1lp0119.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.119]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES128-SHA; 09 Jun 2014 19:39:21 +0900 Received: from [10.161.20.55] (211.11.155.147) by SIXPR06MB333.apcprd06.prod.outlook.com (10.141.120.15) with Microsoft SMTP Server (TLS) id 15.0.954.9; Mon, 9 Jun 2014 10:39:20 +0000 Message-ID: <53958ED5.8070108@renesas.com> Date: Mon, 9 Jun 2014 19:39:17 +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 1/2] net: sh_eth: Fix receive packet "exceeded" condition in sh_eth_rx() X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKXPR04CA003.apcprd04.prod.outlook.com (10.242.96.33) To SIXPR06MB333.apcprd06.prod.outlook.com (10.141.120.15) X-Microsoft-Antispam: BL:0; ACTION:Default; RISK:Low; SCL:0; SPMLVL:NotSpam; PCL:0; RULEID: X-Forefront-PRVS: 02379661A3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(6009001)(6049001)(428001)(199002)(189002)(36756003)(47776003)(20776003)(83506001)(77982001)(23756003)(87976001)(59896001)(85852003)(92566001)(92726001)(54356999)(42186004)(86362001)(65816999)(50986999)(76482001)(87266999)(80022001)(64706001)(83072002)(79102001)(80316001)(46102001)(19580395003)(19580405001)(33656002)(74502001)(81542001)(99136001)(575784001)(74662001)(99396002)(83322001)(101416001)(21056001)(4396001)(31966008)(81342001)(66066001)(50466002)(102836001); DIR:OUT; SFP:; SCL:1; SRVR:SIXPR06MB333; 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..ad0b5bd 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)