All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1 43/50] drivers/isdn: Use get_random_u32()
@ 2019-08-22  0:15 George Spelvin
  0 siblings, 0 replies; only message in thread
From: George Spelvin @ 2019-08-22  0:15 UTC (permalink / raw)
  To: linux-kernel, lkml; +Cc: Karsten Keil, isdn4linux, netdev

There's no need to get_random_bytes() into a temporary buffer.

This is not a no-brainer change; get_random_u32() has slightly weaker
security guarantees, but they're fine for applications like these where
the random value is stored in the kernel for as long as it's
valuable.

Signed-off-by: George Spelvin <lkml@sdf.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: isdn4linux@listserv.isdn4linux.de
Cc: netdev@vger.kernel.org
---
 drivers/isdn/mISDN/tei.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/isdn/mISDN/tei.c b/drivers/isdn/mISDN/tei.c
index 59d28cb19738e..8135e20a667cc 100644
--- a/drivers/isdn/mISDN/tei.c
+++ b/drivers/isdn/mISDN/tei.c
@@ -404,10 +404,7 @@ dl_unit_data(struct manager *mgr, struct sk_buff *skb)
 static unsigned int
 random_ri(void)
 {
-	u16 x;
-
-	get_random_bytes(&x, sizeof(x));
-	return x;
+	return get_random_u32() & 0xffff;
 }
 
 static struct layer2 *
-- 
2.26.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-28 16:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-22  0:15 [RFC PATCH v1 43/50] drivers/isdn: Use get_random_u32() George Spelvin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.