aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/net.h1
-rw-r--r--net/core/utils.c7
2 files changed, 4 insertions, 4 deletions
diff --git a/include/linux/net.h b/include/linux/net.h
index aca446b46754..b292a0435571 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -250,7 +250,6 @@ bool __net_get_random_once(void *buf, int nbytes, bool *done,
250#define ___NET_RANDOM_STATIC_KEY_INIT STATIC_KEY_INIT_FALSE 250#define ___NET_RANDOM_STATIC_KEY_INIT STATIC_KEY_INIT_FALSE
251#endif /* HAVE_JUMP_LABEL */ 251#endif /* HAVE_JUMP_LABEL */
252 252
253/* BE CAREFUL: this function is not interrupt safe */
254#define net_get_random_once(buf, nbytes) \ 253#define net_get_random_once(buf, nbytes) \
255 ({ \ 254 ({ \
256 bool ___ret = false; \ 255 bool ___ret = false; \
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,
370 struct static_key *done_key) 370 struct static_key *done_key)
371{ 371{
372 static DEFINE_SPINLOCK(lock); 372 static DEFINE_SPINLOCK(lock);
373 unsigned long flags;
373 374
374 spin_lock_bh(&lock); 375 spin_lock_irqsave(&lock, flags);
375 if (*done) { 376 if (*done) {
376 spin_unlock_bh(&lock); 377 spin_unlock_irqrestore(&lock, flags);
377 return false; 378 return false;
378 } 379 }
379 380
380 get_random_bytes(buf, nbytes); 381 get_random_bytes(buf, nbytes);
381 *done = true; 382 *done = true;
382 spin_unlock_bh(&lock); 383 spin_unlock_irqrestore(&lock, flags);
383 384
384 __net_random_once_disable_jump(done_key); 385 __net_random_once_disable_jump(done_key);
385 386