aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/utils.c
diff options
context:
space:
mode:
authorHannes Frederic Sowa <[email protected]>2013-10-23 18:05:27 +0000
committerDavid S. Miller <[email protected]>2013-10-25 23:03:39 +0000
commitf84be2bd96a108b09c8440263fa3adb3fb225fa3 (patch)
treead341d7bcd581cba4d38d39296692256d8a747d5 /net/core/utils.c
parentnet: add missing dev_put() in __netdev_adjacent_dev_insert (diff)
downloadkernel-f84be2bd96a108b09c8440263fa3adb3fb225fa3.tar.gz
kernel-f84be2bd96a108b09c8440263fa3adb3fb225fa3.zip
net: make net_get_random_once irq safe
I initial build non irq safe version of net_get_random_once because I would liked to have the freedom to defer even the extraction process of get_random_bytes until the nonblocking pool is fully seeded. I don't think this is a good idea anymore and thus this patch makes net_get_random_once irq safe. Now someone using net_get_random_once does not need to care from where it is called. Cc: David S. Miller <[email protected]> Cc: Eric Dumazet <[email protected]> Signed-off-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'net/core/utils.c')
-rw-r--r--net/core/utils.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/core/utils.c b/net/core/utils.c
index bf09371e19b1..2f737bf90b3f 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -370,16 +370,17 @@ bool __net_get_random_once(void *buf, int nbytes, bool *done,
struct static_key *done_key)
{
static DEFINE_SPINLOCK(lock);
+ unsigned long flags;
- spin_lock_bh(&lock);
+ spin_lock_irqsave(&lock, flags);
if (*done) {
- spin_unlock_bh(&lock);
+ spin_unlock_irqrestore(&lock, flags);
return false;
}
get_random_bytes(buf, nbytes);
*done = true;
- spin_unlock_bh(&lock);
+ spin_unlock_irqrestore(&lock, flags);
__net_random_once_disable_jump(done_key);