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

crypto: caam - fix printing on xts fallback allocation error path

At the time xts fallback tfm allocation fails the device struct
hasn't been enabled yet in the caam xts tfm's private context.

Fix this by using the device struct from xts algorithm's private context
or, when not available, by replacing dev_err with pr_err.

Fixes: 9d9b14dbe077 ("crypto: caam/jr - add fallback for XTS with more than 8B IV")
Fixes: 83e8aa912138 ("crypto: caam/qi - add fallback for XTS with more than 8B IV")
Fixes: 36e2d7cfdcf1 ("crypto: caam/qi2 - add fallback for XTS with more than 8B IV")
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Horia Geantă and committed by
Herbert Xu
ab95bd2a fefc046f

+6 -5
+2 -2
drivers/crypto/caam/caamalg.c
··· 3404 3404 fallback = crypto_alloc_skcipher(tfm_name, 0, 3405 3405 CRYPTO_ALG_NEED_FALLBACK); 3406 3406 if (IS_ERR(fallback)) { 3407 - dev_err(ctx->jrdev, "Failed to allocate %s fallback: %ld\n", 3408 - tfm_name, PTR_ERR(fallback)); 3407 + pr_err("Failed to allocate %s fallback: %ld\n", 3408 + tfm_name, PTR_ERR(fallback)); 3409 3409 return PTR_ERR(fallback); 3410 3410 } 3411 3411
+2 -2
drivers/crypto/caam/caamalg_qi.c
··· 2502 2502 fallback = crypto_alloc_skcipher(tfm_name, 0, 2503 2503 CRYPTO_ALG_NEED_FALLBACK); 2504 2504 if (IS_ERR(fallback)) { 2505 - dev_err(ctx->jrdev, "Failed to allocate %s fallback: %ld\n", 2506 - tfm_name, PTR_ERR(fallback)); 2505 + pr_err("Failed to allocate %s fallback: %ld\n", 2506 + tfm_name, PTR_ERR(fallback)); 2507 2507 return PTR_ERR(fallback); 2508 2508 } 2509 2509
+2 -1
drivers/crypto/caam/caamalg_qi2.c
··· 1611 1611 fallback = crypto_alloc_skcipher(tfm_name, 0, 1612 1612 CRYPTO_ALG_NEED_FALLBACK); 1613 1613 if (IS_ERR(fallback)) { 1614 - dev_err(ctx->dev, "Failed to allocate %s fallback: %ld\n", 1614 + dev_err(caam_alg->caam.dev, 1615 + "Failed to allocate %s fallback: %ld\n", 1615 1616 tfm_name, PTR_ERR(fallback)); 1616 1617 return PTR_ERR(fallback); 1617 1618 }