Skip to content

Commit

Permalink
fakelb: fix schedule while atomic
Browse files Browse the repository at this point in the history
commit bdca1fd upstream.

This patch changes the spinlock to mutex for the available fakelb phy
list. When holding the spinlock the ieee802154_unregister_hw is called
which holding the rtnl_mutex, in that case we get a "BUG: sleeping function
called from invalid context" error. We simple change the spinlock to
mutex which allows to hold the rtnl lock there.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Alexander Aring authored and Greg Kroah-Hartman committed Mar 15, 2017
1 parent bb5b963 commit 77fec8b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/net/ieee802154/fakelb.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
static int numlbs = 2;

static LIST_HEAD(fakelb_phys);
static DEFINE_SPINLOCK(fakelb_phys_lock);
static DEFINE_MUTEX(fakelb_phys_lock);

static LIST_HEAD(fakelb_ifup_phys);
static DEFINE_RWLOCK(fakelb_ifup_phys_lock);
Expand Down Expand Up @@ -180,9 +180,9 @@ static int fakelb_add_one(struct device *dev)
if (err)
goto err_reg;

spin_lock(&fakelb_phys_lock);
mutex_lock(&fakelb_phys_lock);
list_add_tail(&phy->list, &fakelb_phys);
spin_unlock(&fakelb_phys_lock);
mutex_unlock(&fakelb_phys_lock);

return 0;

Expand Down Expand Up @@ -214,21 +214,21 @@ static int fakelb_probe(struct platform_device *pdev)
return 0;

err_slave:
spin_lock(&fakelb_phys_lock);
mutex_lock(&fakelb_phys_lock);
list_for_each_entry_safe(phy, tmp, &fakelb_phys, list)
fakelb_del(phy);
spin_unlock(&fakelb_phys_lock);
mutex_unlock(&fakelb_phys_lock);
return err;
}

static int fakelb_remove(struct platform_device *pdev)
{
struct fakelb_phy *phy, *tmp;

spin_lock(&fakelb_phys_lock);
mutex_lock(&fakelb_phys_lock);
list_for_each_entry_safe(phy, tmp, &fakelb_phys, list)
fakelb_del(phy);
spin_unlock(&fakelb_phys_lock);
mutex_unlock(&fakelb_phys_lock);
return 0;
}

Expand Down

0 comments on commit 77fec8b

Please sign in to comment.