From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-la0-f44.google.com ([209.85.215.44]:41958 "EHLO mail-la0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750964AbaJZIQw (ORCPT ); Sun, 26 Oct 2014 04:16:52 -0400 Received: by mail-la0-f44.google.com with SMTP id hs14so4432978lab.31 for ; Sun, 26 Oct 2014 01:16:51 -0700 (PDT) From: Alexander Aring Subject: [PATCH bluetooth-next 09/15] mac802154: tx: don't allow if down while sync tx Date: Sun, 26 Oct 2014 09:15:46 +0100 Message-Id: <1414311352-908-10-git-send-email-alex.aring@gmail.com> In-Reply-To: <1414311352-908-1-git-send-email-alex.aring@gmail.com> References: <1414311352-908-1-git-send-email-alex.aring@gmail.com> Sender: linux-wpan-owner@vger.kernel.org List-ID: To: linux-wpan@vger.kernel.org Cc: kernel@pengutronix.de, Alexander Aring This patch holds rtnl lock while sync xmit inside of workqueue. Otherwise we could down the interface while worker xmit handling. Signed-off-by: Alexander Aring --- net/mac802154/tx.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c index 1a4f6d9..4439041 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -50,16 +51,28 @@ static void mac802154_xmit_worker(struct work_struct *work) struct sk_buff *skb = cb->skb; int res; + rtnl_lock(); + + /* check if ifdown occurred while schedule */ + if (!netif_running(skb->dev)) + goto err_tx; + res = local->ops->xmit_sync(&local->hw, skb); - if (res) { - pr_debug("transmission failed\n"); - /* Restart the netif queue on each sub_if_data object. */ - ieee802154_wake_queue(&local->hw); - kfree_skb(skb); - } else { - /* Restart the netif queue on each sub_if_data object. */ - ieee802154_xmit_complete(&local->hw, skb); - } + if (res) + goto err_tx; + + ieee802154_xmit_complete(&local->hw, skb); + + rtnl_unlock(); + + return; + +err_tx: + /* Restart the netif queue on each sub_if_data object. */ + ieee802154_wake_queue(&local->hw); + rtnl_unlock(); + kfree_skb(skb); + pr_debug("transmission failed\n"); } static netdev_tx_t -- 2.1.2