* [PATCH] caif: Fix race when conditionally taking rtnl lock
@ 2011-06-01 10:55 Sjur Brændeland
2011-06-02 4:14 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Sjur Brændeland @ 2011-06-01 10:55 UTC (permalink / raw)
To: David S. Miller, netdev; +Cc: Sjur Brændeland
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>
---
net/caif/chnl_net.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
index 649ebac..adbb424 100644
--- a/net/caif/chnl_net.c
+++ b/net/caif/chnl_net.c
@@ -139,17 +139,14 @@ 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();
+
+ 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();
+ rtnl_unlock();
}
static DECLARE_WORK(close_worker, close_work);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] caif: Fix race when conditionally taking rtnl lock
2011-06-01 10:55 [PATCH] caif: Fix race when conditionally taking rtnl lock Sjur Brændeland
@ 2011-06-02 4:14 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-06-02 4:14 UTC (permalink / raw)
To: sjur.brandeland; +Cc: netdev
From: Sjur Brændeland <sjur.brandeland@stericsson.com>
Date: Wed, 1 Jun 2011 12:55:37 +0200
> 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>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-02 4:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-01 10:55 [PATCH] caif: Fix race when conditionally taking rtnl lock Sjur Brændeland
2011-06-02 4:14 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).