Re: [PATCH v3 1/2] crypto: caam - fix pkcs1pad(rsa-caam, sha256) failure because of invalid input

From: Horia Geanta
Date: Mon May 27 2019 - 12:40:36 EST


On 5/24/2019 5:46 PM, Iuliana Prodan wrote:
> @@ -1030,17 +1076,26 @@ int caam_pkc_init(struct device *ctrldev)
> if (!pk_inst)
> return 0;
>
> + /* allocate zero buffer, used for padding input */
> + zero_buffer = kzalloc(CAAM_RSA_MAX_INPUT_SIZE - 1, GFP_DMA |
> + GFP_KERNEL);
> + if (!zero_buffer)
> + err = -ENOMEM;
Either return -ENOMEM or jump to a label before return err.

> +
> err = crypto_register_akcipher(&caam_rsa);
> - if (err)
> + if (err) {
> + kfree(zero_buffer);
> dev_warn(ctrldev, "%s alg registration failed\n",
> caam_rsa.base.cra_driver_name);
> - else
> + } else {
> dev_info(ctrldev, "caam pkc algorithms registered in /proc/crypto\n");
> + }
>
> return err;
> }
>
> void caam_pkc_exit(void)
> {
> + kfree(zero_buffer);
> crypto_unregister_akcipher(&caam_rsa);
> }

Regards,
Horia