crypto: caam - fix endless loop when DECO acquire fails
Pick commit 225ece3 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>
1 parent b6aeb31 commit 4d718b72ba492281ec815b9671a899907db69f15
@Marcin Niestroj Marcin Niestroj authored on 3 Sep 2018
Sascha Hauer committed on 4 Sep 2018
Showing 1 changed file
View
drivers/crypto/caam/ctrl.c