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

Commit 41be5a4a authored by sjur.brandeland@stericsson.com's avatar sjur.brandeland@stericsson.com Committed by David S. Miller
Browse files

caif: Fix race when conditionally taking rtnl lock



Take the RTNL lock unconditionally when calling dev_close.
Taking the lock conditionally may cause race conditions.

Signed-off-by: default avatarSjur Brændeland <sjur.brandeland@stericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 85e3c65f
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -139,16 +139,13 @@ static void close_work(struct work_struct *work)
	struct chnl_net *dev = NULL;
	struct list_head *list_node;
	struct list_head *_tmp;
	/* May be called with or without RTNL lock held */
	int islocked = rtnl_is_locked();
	if (!islocked)

	rtnl_lock();
	list_for_each_safe(list_node, _tmp, &chnl_net_list) {
		dev = list_entry(list_node, struct chnl_net, list_field);
		if (dev->state == CAIF_SHUTDOWN)
			dev_close(dev->netdev);
	}
	if (!islocked)
	rtnl_unlock();
}
static DECLARE_WORK(close_worker, close_work);