]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
crypto: cavium - Fix an error handling path in cpt_ucode_load_fw()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 8 Nov 2024 17:22:27 +0000 (18:22 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 15 Nov 2024 11:52:51 +0000 (19:52 +0800)
If do_cpt_init() fails, a previous dma_alloc_coherent() call needs to be
undone.

Add the needed dma_free_coherent() before returning.

Fixes: 9e2c7d99941d ("crypto: cavium - Add Support for Octeon-tx CPT Engine")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/cavium/cpt/cptpf_main.c

index ec17beee24c07deae0196c8d81c3dae5f27fd6fb..54de869e5374c29d07ad20baccd986705146b2c1 100644 (file)
@@ -302,6 +302,8 @@ static int cpt_ucode_load_fw(struct cpt_device *cpt, const u8 *fw, bool is_ae)
 
        ret = do_cpt_init(cpt, mcode);
        if (ret) {
+               dma_free_coherent(&cpt->pdev->dev, mcode->code_size,
+                                 mcode->code, mcode->phys_base);
                dev_err(dev, "do_cpt_init failed with ret: %d\n", ret);
                goto fw_release;
        }