crypto: caam - fix endless loop when DECO acquire fails
authorHoria Geantă <horia.geanta@nxp.com>
Mon, 5 Feb 2018 09:15:52 +0000 (11:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Feb 2018 12:21:17 +0000 (13:21 +0100)
commita96e820790253c8971ef08670c9c8dd43b619fda
treeb494f3e4ad16b869099147d6dcc01975b7aa6b4d
parentf2d4bed9eabf1636adbf538865e06876e18807e8
crypto: caam - fix endless loop when DECO acquire fails

commit 225ece3e7dad4cfc44cca38ce7a3a80f255ea8f1 upstream.

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.

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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/crypto/caam/ctrl.c