Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto fix from Herbert Xu:
"This fixes a bug where qcom-rng can return a buffer that is not
completely filled with random data"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: qcom-rng - ensure buffer for generate is completely filled

+10 -7
+10 -7
drivers/crypto/qcom-rng.c
··· 8 8 #include <linux/clk.h> 9 9 #include <linux/crypto.h> 10 10 #include <linux/io.h> 11 + #include <linux/iopoll.h> 11 12 #include <linux/module.h> 12 13 #include <linux/of.h> 13 14 #include <linux/platform_device.h> ··· 44 43 { 45 44 unsigned int currsize = 0; 46 45 u32 val; 46 + int ret; 47 47 48 48 /* read random data from hardware */ 49 49 do { 50 - val = readl_relaxed(rng->base + PRNG_STATUS); 51 - if (!(val & PRNG_STATUS_DATA_AVAIL)) 52 - break; 50 + ret = readl_poll_timeout(rng->base + PRNG_STATUS, val, 51 + val & PRNG_STATUS_DATA_AVAIL, 52 + 200, 10000); 53 + if (ret) 54 + return ret; 53 55 54 56 val = readl_relaxed(rng->base + PRNG_DATA_OUT); 55 57 if (!val) 56 - break; 58 + return -EINVAL; 57 59 58 60 if ((max - currsize) >= WORD_SZ) { 59 61 memcpy(data, &val, WORD_SZ); ··· 65 61 } else { 66 62 /* copy only remaining bytes */ 67 63 memcpy(data, &val, max - currsize); 68 - break; 69 64 } 70 65 } while (currsize < max); 71 66 72 - return currsize; 67 + return 0; 73 68 } 74 69 75 70 static int qcom_rng_generate(struct crypto_rng *tfm, ··· 90 87 mutex_unlock(&rng->lock); 91 88 clk_disable_unprepare(rng->clk); 92 89 93 - return 0; 90 + return ret; 94 91 } 95 92 96 93 static int qcom_rng_seed(struct crypto_rng *tfm, const u8 *seed,