Skip to content

Commit 41be5a4

Browse files
sjur.brandeland@stericsson.comdavem330
authored andcommitted
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: Sjur Brændeland <sjur.brandeland@stericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 85e3c65 commit 41be5a4

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

net/caif/chnl_net.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,14 @@ static void close_work(struct work_struct *work)
139139
struct chnl_net *dev = NULL;
140140
struct list_head *list_node;
141141
struct list_head *_tmp;
142-
/* May be called with or without RTNL lock held */
143-
int islocked = rtnl_is_locked();
144-
if (!islocked)
145-
rtnl_lock();
142+
143+
rtnl_lock();
146144
list_for_each_safe(list_node, _tmp, &chnl_net_list) {
147145
dev = list_entry(list_node, struct chnl_net, list_field);
148146
if (dev->state == CAIF_SHUTDOWN)
149147
dev_close(dev->netdev);
150148
}
151-
if (!islocked)
152-
rtnl_unlock();
149+
rtnl_unlock();
153150
}
154151
static DECLARE_WORK(close_worker, close_work);
155152

0 commit comments

Comments
 (0)