Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fa2cffe authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann
Browse files

fakelb: move lock out of iteration



The list need to be protected while iteration which is need when other
list iterates at the same time over this list.

Signed-off-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent b82b99f1
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -193,9 +193,7 @@ static int fakelb_add_one(struct device *dev)

static void fakelb_del(struct fakelb_phy *phy)
{
	write_lock_bh(&fakelb_lock);
	list_del(&phy->list);
	write_unlock_bh(&fakelb_lock);

	ieee802154_unregister_hw(phy->hw);
	ieee802154_free_hw(phy->hw);
@@ -217,8 +215,10 @@ static int fakelb_probe(struct platform_device *pdev)
	return 0;

err_slave:
	write_lock_bh(&fakelb_lock);
	list_for_each_entry_safe(phy, tmp, &fakelb_phys, list)
		fakelb_del(phy);
	write_unlock_bh(&fakelb_lock);
	return err;
}

@@ -226,9 +226,10 @@ static int fakelb_remove(struct platform_device *pdev)
{
	struct fakelb_phy *phy, *temp;

	write_lock_bh(&fakelb_lock);
	list_for_each_entry_safe(phy, temp, &fakelb_phys, list)
		fakelb_del(phy);

	write_unlock_bh(&fakelb_lock);
	return 0;
}