random: Include <linux/once.h> in the right header

Message ID 212adb212cb0234a7d395daf31b2578b9409d492.1670015476.git.christophe.jaillet@wanadoo.fr
State New
Headers
Series random: Include <linux/once.h> in the right header |

Commit Message

Christophe JAILLET Dec. 2, 2022, 9:13 p.m. UTC
  <linux/prandom.h> uses DO_ONCE(). So it should include <linux/once.h>
directly.

On the contrary, <linux/random.h> doesn't use functionalities from
<linux/once.h>, so it should be removed.

All this is true since commit c0842fbc1b18 ("random32: move the
pseudo-random 32-bit definitions to prandom.h")

Move the #include <linux/once.h> in the right file.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Let see if build-bots agree with me!
---
 include/linux/prandom.h | 1 +
 include/linux/random.h  | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
  

Comments

Kees Cook Dec. 2, 2022, 9:17 p.m. UTC | #1
On Fri, Dec 02, 2022 at 10:13:36PM +0100, Christophe JAILLET wrote:
> <linux/prandom.h> uses DO_ONCE(). So it should include <linux/once.h>
> directly.
> 
> On the contrary, <linux/random.h> doesn't use functionalities from
> <linux/once.h>, so it should be removed.
> 
> All this is true since commit c0842fbc1b18 ("random32: move the
> pseudo-random 32-bit definitions to prandom.h")
> 
> Move the #include <linux/once.h> in the right file.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Kees Cook <keescook@chromium.org>
  
Jason A. Donenfeld Dec. 3, 2022, 1:03 a.m. UTC | #2
Hi Christophe,

On Fri, Dec 02, 2022 at 10:13:36PM +0100, Christophe JAILLET wrote:
> <linux/prandom.h> uses DO_ONCE(). So it should include <linux/once.h>
> directly.
> 
> On the contrary, <linux/random.h> doesn't use functionalities from
> <linux/once.h>, so it should be removed.
> 
> All this is true since commit c0842fbc1b18 ("random32: move the
> pseudo-random 32-bit definitions to prandom.h")
> 
> Move the #include <linux/once.h> in the right file.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Thanks, applied for now as:
https://git.kernel.org/pub/scm/linux/kernel/git/crng/random.git/commit/?id=1ea746beac98ad11132b0a9a11978d5cf0a055ef

> ---
> Let see if build-bots agree with me!

Indeed. I've got a few builds of my own going, and so far so good, but
we'll learn soon enough if something goes wrong.

Jason
  

Patch

diff --git a/include/linux/prandom.h b/include/linux/prandom.h
index 1f4a0de7b019..c94c02ba065c 100644
--- a/include/linux/prandom.h
+++ b/include/linux/prandom.h
@@ -9,6 +9,7 @@ 
 #define _LINUX_PRANDOM_H
 
 #include <linux/types.h>
+#include <linux/once.h>
 #include <linux/percpu.h>
 #include <linux/random.h>
 
diff --git a/include/linux/random.h b/include/linux/random.h
index b1a34181eed6..4a2a1de423cd 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -6,7 +6,6 @@ 
 #include <linux/bug.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
-#include <linux/once.h>
 
 #include <uapi/linux/random.h>