[PATCH] crypto: crc32: create crc table only once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We use crc_table[0] != 0 as indicator if we have already generated the
crc table. crc_table[0] will be generated as 0x0 though, so we end up
generating the crc table over and over again. Use crc_table[1] as
indicator instead.

Fixes: b00801710b ("crypto: crc32: allocate crc_table statically")
Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 crypto/crc32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/crc32.c b/crypto/crc32.c
index 287dfa3303..49d0b49c65 100644
--- a/crypto/crc32.c
+++ b/crypto/crc32.c
@@ -56,7 +56,7 @@ static void make_crc_table(void)
 	/* terms of polynomial defining this crc (except x^32): */
 	static const char p[] = { 0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26 };
 
-	if (crc_table[0])
+	if (crc_table[1])
 		return;
 
 	/* make exclusive-or pattern from polynomial (0xedb88320L) */
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux