Remove useless assignment of ret to -ENOMEM in rsa_verify. Remove useless initialization of ret to zero at declaration in rsa_enc/dec/sign/verify. Benefit of the power of undefined values and set ret in branches in rsa_enc/dec/sign. Reported-by: Benjamin Bales <techsupport@xxxxxxxxx> Signed-off-by: Tudor Ambarus <tudor.ambarus@xxxxxxxxxxxxx> --- crypto/rsa.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/crypto/rsa.c b/crypto/rsa.c index b067f3a..e75ce09 100644 --- a/crypto/rsa.c +++ b/crypto/rsa.c @@ -88,7 +88,7 @@ static int rsa_enc(struct akcipher_request *req) struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req); const struct rsa_mpi_key *pkey = rsa_get_key(tfm); MPI m, c = mpi_alloc(0); - int ret = 0; + int ret; int sign; if (!c) @@ -99,10 +99,11 @@ static int rsa_enc(struct akcipher_request *req) goto err_free_c; } - ret = -ENOMEM; m = mpi_read_raw_from_sgl(req->src, req->src_len); - if (!m) + if (!m) { + ret = -ENOMEM; goto err_free_c; + } ret = _rsa_enc(pkey, c, m); if (ret) @@ -127,7 +128,7 @@ static int rsa_dec(struct akcipher_request *req) struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req); const struct rsa_mpi_key *pkey = rsa_get_key(tfm); MPI c, m = mpi_alloc(0); - int ret = 0; + int ret; int sign; if (!m) @@ -138,10 +139,11 @@ static int rsa_dec(struct akcipher_request *req) goto err_free_m; } - ret = -ENOMEM; c = mpi_read_raw_from_sgl(req->src, req->src_len); - if (!c) + if (!c) { + ret = -ENOMEM; goto err_free_m; + } ret = _rsa_dec(pkey, m, c); if (ret) @@ -165,7 +167,7 @@ static int rsa_sign(struct akcipher_request *req) struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req); const struct rsa_mpi_key *pkey = rsa_get_key(tfm); MPI m, s = mpi_alloc(0); - int ret = 0; + int ret; int sign; if (!s) @@ -176,10 +178,11 @@ static int rsa_sign(struct akcipher_request *req) goto err_free_s; } - ret = -ENOMEM; m = mpi_read_raw_from_sgl(req->src, req->src_len); - if (!m) + if (!m) { + ret = -ENOMEM; goto err_free_s; + } ret = _rsa_sign(pkey, s, m); if (ret) @@ -204,7 +207,7 @@ static int rsa_verify(struct akcipher_request *req) struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req); const struct rsa_mpi_key *pkey = rsa_get_key(tfm); MPI s, m = mpi_alloc(0); - int ret = 0; + int ret; int sign; if (!m) @@ -215,7 +218,6 @@ static int rsa_verify(struct akcipher_request *req) goto err_free_m; } - ret = -ENOMEM; s = mpi_read_raw_from_sgl(req->src, req->src_len); if (!s) { ret = -ENOMEM; -- 2.9.4