Re: [PATCH] crypto: arm64/aes-neonbs - remove redundant code in __xts_crypt()

From: Ard Biesheuvel
Date: Tue Oct 22 2019 - 02:52:53 EST


On Tue, 22 Oct 2019 at 08:42, Yunfeng Ye <yeyunfeng@xxxxxxxxxx> wrote:
>
> A warning is found by the static code analysis tool:
> "Identical condition 'err', second condition is always false"
>
> Fix this by removing the redundant condition @err.
>
> Signed-off-by: Yunfeng Ye <yeyunfeng@xxxxxxxxxx>

Please don't blindly 'fix' crypto code without reading it carefully
and without cc'ing the author.

The correct fix is to add the missing assignment of 'err', like so

diff --git a/arch/arm64/crypto/aes-neonbs-glue.c
b/arch/arm64/crypto/aes-neonbs-glue.c
index ea873b8904c4..e3e27349a9fe 100644
--- a/arch/arm64/crypto/aes-neonbs-glue.c
+++ b/arch/arm64/crypto/aes-neonbs-glue.c
@@ -384,7 +384,7 @@ static int __xts_crypt(struct skcipher_request
*req, bool encrypt,
goto xts_tail;

kernel_neon_end();
- skcipher_walk_done(&walk, nbytes);
+ err = skcipher_walk_done(&walk, nbytes);
}

if (err || likely(!tail))

Does that make the warning go away?


> ---
> arch/arm64/crypto/aes-neonbs-glue.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/crypto/aes-neonbs-glue.c b/arch/arm64/crypto/aes-neonbs-glue.c
> index ea873b8904c4..7b342db428b0 100644
> --- a/arch/arm64/crypto/aes-neonbs-glue.c
> +++ b/arch/arm64/crypto/aes-neonbs-glue.c
> @@ -387,7 +387,7 @@ static int __xts_crypt(struct skcipher_request *req, bool encrypt,
> skcipher_walk_done(&walk, nbytes);
> }
>
> - if (err || likely(!tail))
> + if (likely(!tail))
> return err;
>
> /* handle ciphertext stealing */
> --
> 2.7.4.3
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel