From patchwork Wed Nov 18 22:39:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 7653171 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BC1F4BF90C for ; Wed, 18 Nov 2015 22:39:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA5D9204A9 for ; Wed, 18 Nov 2015 22:39:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 53781204A2 for ; Wed, 18 Nov 2015 22:39:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757111AbbKRWj4 (ORCPT ); Wed, 18 Nov 2015 17:39:56 -0500 Received: from mail-lf0-f45.google.com ([209.85.215.45]:36275 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755998AbbKRWjz (ORCPT ); Wed, 18 Nov 2015 17:39:55 -0500 Received: by lfs39 with SMTP id 39so36508815lfs.3 for ; Wed, 18 Nov 2015 14:39:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:organization:user-agent :mime-version:content-transfer-encoding:content-type; bh=mXaUQdh+awRUQ5z0+36D1tFW4vlgANeiFcmA4LdQz7Y=; b=cdBF2kd35EuZKtwnjbAsXC5pZThGL7k9DmCxbn2Q/3e7GEZwq59WhqnszVmgEKcinX dGlR8PgOBXcPTgWMVxhWSXiBGfbarFah4zgthp6PSBpYMUHyejEv6colyhtXZs8SgZhL z2koWQWgMRr/sGo0wi6Ue8laYTQi0hyMZzAaJZN7UoYn4I6nvxIUdocOE9SG+OwZCtXp GakotvSM7avJ17HeKkO8fN/eOp+wOt76s1jgSL3N9SLNNZaa1vk51mH377fsXw5MqHgp qBmtLNDGYymA26vlvnBvktCVQ4Un07vYP4SsJXzXEnKYRGZsRR7e0HjrPVFGqvWzAAVv GUeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:mime-version:content-transfer-encoding:content-type; bh=mXaUQdh+awRUQ5z0+36D1tFW4vlgANeiFcmA4LdQz7Y=; b=MMQSfzS5aZZz+mfvM3X5D5BT2VgSz1+zSeOq0bRpbl3K9dnubicIVIIyUS9GH2KPNf yodr+Iq3h3c/Ce6xuwQaabcDwP8bHSFMxFcaoz5X6qO3BdnLl1mmBApZb9GVVhxBNmd0 MWZED7HAMcImfmg6vXfRoWetUs7k9QB02bLT9RZOYvQoIigCIwtrmNCQ5C7LoS7lewrh 8quPoWa3LUlgLrwGeHcFGhL4tQrnuCm8v9iJmWGYUwDxMLUxfzl8t/8N0lLtrKgSFQoK bujomb0Znu4bssoOH0j8CCakY5R/HYqggqUtMAEkUNs0rpURmOavHkUcYbdWeo+f7sE8 5cxA== X-Gm-Message-State: ALoCoQm9/8FFupm2O+its4hxvcTVRvwanEU8p0BVKBW5Nq9TdCQhuyk0dIrPK+QAVmt/dUKzeV7g X-Received: by 10.25.20.160 with SMTP id 32mr1866782lfu.28.1447886393638; Wed, 18 Nov 2015 14:39:53 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.84.30]) by smtp.gmail.com with ESMTPSA id i13sm749868lfe.9.2015.11.18.14.39.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Nov 2015 14:39:52 -0800 (PST) From: Sergei Shtylyov To: netdev@vger.kernel.org Cc: linux-sh@vger.kernel.org, kazuya.mizuguchi.ks@renesas.com, horms+renesas@verge.net.au Subject: [PATCH] ravb: fix WARNING in __free_irq() Date: Thu, 19 Nov 2015 01:39:51 +0300 Message-ID: <4607844.sdhchmu5cM@wasted.cogentembedded.com> Organization: Cogent Embedded Inc. User-Agent: KMail/4.14.9 (Linux/4.2.5-201.fc22.x86_64; KDE/4.14.13; x86_64; ; ) MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the R8A7795 support was added to the driver, little attention was paid to the ravb_open() error path: free_irq() for the EMAC interrupt was called uncoditionally, unlike request_irq(), and in a wrong order as well... As a result, on the R-Car gen2 SoCs I started getting the following in case of a device opening error: WARNING: CPU: 0 PID: 1 at kernel/irq/manage.c:1448 __free_irq+0x8c/0x228() Trying to free already-free IRQ 0 Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.4.0-rc1-dirty #1005 Hardware name: Generic R8A7791 (Flattened Device Tree) Backtrace: [] (dump_backtrace) from [] (show_stack+0x18/0x1c) r6:c063cdd6 r5:00000009 r4:00000000 r3:00204140 [] (show_stack) from [] (dump_stack+0x74/0x90) [] (dump_stack) from [] (warn_slowpath_common+0x8c/0xb8) r4:ef04fd38 r3:c0714770 [] (warn_slowpath_common) from [] (warn_slowpath_fmt+0x38/0x40) r8:ee8ad800 r7:ef0030a0 r6:00000000 r5:00000000 r4:ef003040 [] (warn_slowpath_fmt) from [] (__free_irq+0x8c/0x228) r3:00000000 r2:c063ce9f [] (__free_irq) from [] (free_irq+0x70/0xa4) r10:0000016b r8:00000000 r7:00000000 r6:ee8ad800 r5:00000000 r4:ef003040 [] (free_irq) from [] (ravb_open+0x224/0x274) r7:fffffffe r6:00000000 r5:fffffffe r4:ee8ad800 [] (ravb_open) from [] (__dev_open+0x84/0x104) r7:ee8ad830 r6:c0566334 r5:00000000 r4:ee8ad800 [] (__dev_open) from [] (__dev_change_flags+0x94/0x13c) r7:00001002 r6:00000001 r5:00001003 r4:ee8ad800 [] (__dev_change_flags) from [] (dev_change_flags+0x20/0x50) r7:c072e6e0 r6:00000138 r5:00001002 r4:ee8ad800 [] (dev_change_flags) from [] (ip_auto_config+0x174/0xfb8) r8:00001002 r7:c072e6e0 r6:c0703344 r5:00000001 r4:ee8ad800 r3:00000101 [] (ip_auto_config) from [] (do_one_initcall+0x100/0x1cc) r10:c06fb83c r9:00000000 r8:c06ebef8 r7:c0736000 r6:c0710918 r5:c0710918 r4:ef2f8f80 [] (do_one_initcall) from [] (kernel_init_freeable+0x11c/0x1 ec) r10:c06fb83c r9:00000000 r8:0000009a r7:c0736000 r6:c0706bf0 r5:c06fb834 r4:00000007 [] (kernel_init_freeable) from [] (kernel_init+0x14/0xec) r10:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c0514c40 r4:c0736000 [] (kernel_init) from [] (ret_from_fork+0x14/0x3c) r4:00000000 r3:ef04e000 Fix up the free_irq() call order and add a new label on the error path. Fixes: 22d4df8ff3a3 ("ravb: Add support for r8a7795 SoC") Signed-off-by: Sergei Shtylyov Acked-by: Simon Horman --- The patch is against DaveM's 'net.git' repo. drivers/net/ethernet/renesas/ravb_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: net/drivers/net/ethernet/renesas/ravb_main.c =================================================================== --- net.orig/drivers/net/ethernet/renesas/ravb_main.c +++ net/drivers/net/ethernet/renesas/ravb_main.c @@ -1225,7 +1225,7 @@ static int ravb_open(struct net_device * /* Device init */ error = ravb_dmac_init(ndev); if (error) - goto out_free_irq; + goto out_free_irq2; ravb_emac_init(ndev); /* Initialise PTP Clock driver */ @@ -1243,9 +1243,11 @@ static int ravb_open(struct net_device * out_ptp_stop: /* Stop PTP Clock driver */ ravb_ptp_stop(ndev); +out_free_irq2: + if (priv->chip_id == RCAR_GEN3) + free_irq(priv->emac_irq, ndev); out_free_irq: free_irq(ndev->irq, ndev); - free_irq(priv->emac_irq, ndev); out_napi_off: napi_disable(&priv->napi[RAVB_NC]); napi_disable(&priv->napi[RAVB_BE]);