diff options
author | Marcin Niestroj <m.niestroj@grinn-global.com> | 2018-09-03 13:24:04 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-09-04 10:03:49 +0200 |
commit | 4d718b72ba492281ec815b9671a899907db69f15 (patch) | |
tree | 1d716c1852e7d812a4b41b27e79805e5d242fe9c /drivers/crypto | |
parent | b6aeb311a993e564cdb8a99d0b5797350b6e54b0 (diff) | |
download | barebox-4d718b72ba492281ec815b9671a899907db69f15.tar.gz barebox-4d718b72ba492281ec815b9671a899907db69f15.tar.xz |
crypto: caam - fix endless loop when DECO acquire fails
Pick commit 225ece3e7dad4cfc44cca38ce7a3a80f255ea8f1 from Linux
upstream.
crypto: caam - fix endless loop when DECO acquire fails
In case DECO0 cannot be acquired - i.e. run_descriptor_deco0() fails
with -ENODEV, caam_probe() enters an endless loop:
run_descriptor_deco0
ret -ENODEV
-> instantiate_rng
-ENODEV, overwritten by -EAGAIN
ret -EAGAIN
-> caam_probe
-EAGAIN results in endless loop
It turns out the error path in instantiate_rng() is incorrect,
the checks are done in the wrong order.
Cc: <stable@vger.kernel.org> # 3.13+
Fixes: 1005bccd7a4a6 ("crypto: caam - enable instantiation of all RNG4 state handles")
Reported-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Suggested-by: Auer Lukas <lukas.auer@aisec.fraunhofer.de>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/caam/ctrl.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 0f9ad328e0..6812005948 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -202,12 +202,15 @@ static int instantiate_rng(struct device_d *ctrldev, int state_handle_mask, * without any error (HW optimizations for later * CAAM eras), then try again. */ + if (ret) + break; + rdsta_val = rd_reg32(&ctrl->r4tst[0].rdsta) & RDSTA_IFMASK; if ((status && status != JRSTA_SSRC_JUMP_HALT_CC) || - !(rdsta_val & (1 << sh_idx))) + !(rdsta_val & (1 << sh_idx))) { ret = -EAGAIN; - if (ret) break; + } dev_info(ctrldev, "Instantiated RNG4 SH%d\n", sh_idx); /* Clear the contents before recreating the descriptor */ memset(desc, 0x00, CAAM_CMD_SZ * 7); |