* [PATCH] crypto: cavium/nitrox - Fix an erro rhandling path in 'nitrox_probe()'
@ 2021-06-05 12:55 Christophe JAILLET
2021-06-11 7:24 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2021-06-05 12:55 UTC (permalink / raw)
To: herbert, davem, gregkh, acostag.ubuntu, lee.jones, Jampala.Srikanth
Cc: linux-crypto, linux-kernel, kernel-janitors, Christophe JAILLET
If an error occurs after a successful 'ioremap()' call, it must be undone
by a corresponding 'iounmap()' call, as already done in the remove
function.
Ass a 'pf_sw_fail' label in the error handling path and add the missing
'iounmap()'.
While at it, also add a 'flr_fail' label in the error handling path and use
it to avoid some code duplication.
Fixes: 14fa93cdcd9b ("crypto: cavium - Add support for CNN55XX adapters.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/crypto/cavium/nitrox/nitrox_main.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c b/drivers/crypto/cavium/nitrox/nitrox_main.c
index 144d554bd44d..96bc7b5c6532 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_main.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_main.c
@@ -424,8 +424,7 @@ static int nitrox_probe(struct pci_dev *pdev,
err = nitrox_device_flr(pdev);
if (err) {
dev_err(&pdev->dev, "FLR failed\n");
- pci_disable_device(pdev);
- return err;
+ goto flr_fail;
}
if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) {
@@ -434,16 +433,13 @@ static int nitrox_probe(struct pci_dev *pdev,
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (err) {
dev_err(&pdev->dev, "DMA configuration failed\n");
- pci_disable_device(pdev);
- return err;
+ goto flr_fail;
}
}
err = pci_request_mem_regions(pdev, nitrox_driver_name);
- if (err) {
- pci_disable_device(pdev);
- return err;
- }
+ if (err)
+ goto flr_fail;
pci_set_master(pdev);
ndev = kzalloc(sizeof(*ndev), GFP_KERNEL);
@@ -479,7 +475,7 @@ static int nitrox_probe(struct pci_dev *pdev,
err = nitrox_pf_sw_init(ndev);
if (err)
- goto ioremap_err;
+ goto pf_sw_fail;
err = nitrox_pf_hw_init(ndev);
if (err)
@@ -509,12 +505,15 @@ static int nitrox_probe(struct pci_dev *pdev,
smp_mb__after_atomic();
pf_hw_fail:
nitrox_pf_sw_cleanup(ndev);
+pf_sw_fail:
+ iounmap(ndev->bar_addr);
ioremap_err:
nitrox_remove_from_devlist(ndev);
kfree(ndev);
pci_set_drvdata(pdev, NULL);
ndev_fail:
pci_release_mem_regions(pdev);
+flr_fail:
pci_disable_device(pdev);
return err;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: cavium/nitrox - Fix an erro rhandling path in 'nitrox_probe()'
2021-06-05 12:55 [PATCH] crypto: cavium/nitrox - Fix an erro rhandling path in 'nitrox_probe()' Christophe JAILLET
@ 2021-06-11 7:24 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2021-06-11 7:24 UTC (permalink / raw)
To: Christophe JAILLET
Cc: davem, gregkh, acostag.ubuntu, lee.jones, Jampala.Srikanth,
linux-crypto, linux-kernel, kernel-janitors
On Sat, Jun 05, 2021 at 02:55:56PM +0200, Christophe JAILLET wrote:
> If an error occurs after a successful 'ioremap()' call, it must be undone
> by a corresponding 'iounmap()' call, as already done in the remove
> function.
> Ass a 'pf_sw_fail' label in the error handling path and add the missing
> 'iounmap()'.
>
> While at it, also add a 'flr_fail' label in the error handling path and use
> it to avoid some code duplication.
>
> Fixes: 14fa93cdcd9b ("crypto: cavium - Add support for CNN55XX adapters.")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/crypto/cavium/nitrox/nitrox_main.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-11 7:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-05 12:55 [PATCH] crypto: cavium/nitrox - Fix an erro rhandling path in 'nitrox_probe()' Christophe JAILLET
2021-06-11 7:24 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).