Skip to content

Commit cca2a7a

Browse files
zx2c4gregkh
authored andcommitted
nios2: use fallback for random_get_entropy() instead of zero
commit c04e727 upstream. In the event that random_get_entropy() can't access a cycle counter or similar, falling back to returning 0 is really not the best we can do. Instead, at least calling random_get_entropy_fallback() would be preferable, because that always needs to return _something_, even falling back to jiffies eventually. It's not as though random_get_entropy_fallback() is super high precision or guaranteed to be entropic, but basically anything that's not zero all the time is better than returning zero all the time. Cc: Thomas Gleixner <[email protected]> Cc: Arnd Bergmann <[email protected]> Acked-by: Dinh Nguyen <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a9ebafb commit cca2a7a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/nios2/include/asm/timex.h

+3
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
typedef unsigned long cycles_t;
99

1010
extern cycles_t get_cycles(void);
11+
#define get_cycles get_cycles
12+
13+
#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback())
1114

1215
#endif

0 commit comments

Comments
 (0)