]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ieee802154: netlink add rtnl lock
authorAlexander Aring <alex.aring@gmail.com>
Sun, 9 Nov 2014 07:36:57 +0000 (08:36 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 9 Nov 2014 18:50:29 +0000 (19:50 +0100)
This patch adds rtnl lock hold mechanism while accessing wpan_dev
attributes. Furthermore these attributes should be protected by rtnl
lock and netif_running only.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/ieee802154/nl-mac.c
net/mac802154/mac_cmd.c

index 7127b9d1a68409457a1d570117ca1a962b6f2293..50e9863823a5035f78fc209260991a3da31a2ddb 100644 (file)
@@ -113,7 +113,9 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid,
        if (ops->get_mac_params) {
                struct ieee802154_mac_params params;
 
+               rtnl_lock();
                ops->get_mac_params(dev, &params);
+               rtnl_unlock();
 
                if (nla_put_s8(msg, IEEE802154_ATTR_TXPOWER,
                               params.transmit_power) ||
@@ -348,8 +350,10 @@ int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info)
                return -EINVAL;
        }
 
+       rtnl_lock();
        ret = ieee802154_mlme_ops(dev)->start_req(dev, &addr, channel, page,
                bcn_ord, sf_ord, pan_coord, blx, coord_realign);
+       rtnl_unlock();
 
        /* FIXME: add validation for unused parameters to be sane
         * for SoftMAC
@@ -497,6 +501,7 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info)
        phy = dev->ieee802154_ptr->wpan_phy;
        get_device(&phy->dev);
 
+       rtnl_lock();
        ops->get_mac_params(dev, &params);
 
        if (info->attrs[IEEE802154_ATTR_TXPOWER])
@@ -524,6 +529,7 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info)
                params.frame_retries = nla_get_s8(info->attrs[IEEE802154_ATTR_FRAME_RETRIES]);
 
        rc = ops->set_mac_params(dev, &params);
+       rtnl_unlock();
 
        wpan_phy_put(phy);
        dev_put(dev);
index b8bd95263aabc25c5c72034650a8b717d9fefd44..6aacb181688961178bab9849c23425a7a3e25478 100644 (file)
@@ -39,6 +39,8 @@ static int mac802154_mlme_start_req(struct net_device *dev,
        struct ieee802154_mlme_ops *ops = ieee802154_mlme_ops(dev);
        int rc = 0;
 
+       ASSERT_RTNL();
+
        BUG_ON(addr->mode != IEEE802154_ADDR_SHORT);
 
        mac802154_dev_set_pan_id(dev, addr->pan_id);
@@ -75,7 +77,8 @@ static int mac802154_set_mac_params(struct net_device *dev,
        struct wpan_dev *wpan_dev = &sdata->wpan_dev;
        int ret;
 
-       mutex_lock(&sdata->local->iflist_mtx);
+       ASSERT_RTNL();
+
        /* PHY */
        wpan_dev->wpan_phy->transmit_power = params->transmit_power;
        wpan_dev->wpan_phy->cca_mode = params->cca_mode;
@@ -87,7 +90,6 @@ static int mac802154_set_mac_params(struct net_device *dev,
        wpan_dev->csma_retries = params->csma_retries;
        wpan_dev->frame_retries = params->frame_retries;
        wpan_dev->lbt = params->lbt;
-       mutex_unlock(&sdata->local->iflist_mtx);
 
        if (local->hw.flags & IEEE802154_HW_TXPOWER) {
                ret = drv_set_tx_power(local, params->transmit_power);
@@ -116,7 +118,8 @@ static void mac802154_get_mac_params(struct net_device *dev,
        struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
        struct wpan_dev *wpan_dev = &sdata->wpan_dev;
 
-       mutex_lock(&sdata->local->iflist_mtx);
+       ASSERT_RTNL();
+
        /* PHY */
        params->transmit_power = wpan_dev->wpan_phy->transmit_power;
        params->cca_mode = wpan_dev->wpan_phy->cca_mode;
@@ -128,7 +131,6 @@ static void mac802154_get_mac_params(struct net_device *dev,
        params->csma_retries = wpan_dev->csma_retries;
        params->frame_retries = wpan_dev->frame_retries;
        params->lbt = wpan_dev->lbt;
-       mutex_unlock(&sdata->local->iflist_mtx);
 }
 
 static struct ieee802154_llsec_ops mac802154_llsec_ops = {