diff mbox series

ethernet: sun: Fix an error handling path in happy_meal_pci_probe()

Message ID 242ebc5e7dedc6b0d7f47cbf7768326c127f955b.1646584729.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series ethernet: sun: Fix an error handling path in happy_meal_pci_probe() | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Christophe JAILLET March 6, 2022, 4:39 p.m. UTC
A dma_free_coherent() call is missing in the error handling path of the
probe, as already done in the remove function.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
dma_alloc_coherent() uses '&pdev->dev' and the remove function
'hp->dma_dev'.
This change is a copy&paste from the remove function, so I've left the
latter. It is not important because on line 3017 we have
"hp->dma_dev = &pdev->dev;" so both expression are the same.


I've not been able to find a Fixes tag because of the renaming of
function and files.
However, it looks old (before 2008)
---
 drivers/net/ethernet/sun/sunhme.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski March 8, 2022, 6:24 a.m. UTC | #1
On Sun,  6 Mar 2022 17:39:10 +0100 Christophe JAILLET wrote:
> A dma_free_coherent() call is missing in the error handling path of the
> probe, as already done in the remove function.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> dma_alloc_coherent() uses '&pdev->dev' and the remove function
> 'hp->dma_dev'.
> This change is a copy&paste from the remove function, so I've left the
> latter. It is not important because on line 3017 we have
> "hp->dma_dev = &pdev->dev;" so both expression are the same.
> 
> 
> I've not been able to find a Fixes tag because of the renaming of
> function and files.
> However, it looks old (before 2008)

Looks like we got an identical fix from someone else a day earlier:

https://lore.kernel.org/all/1646492104-23040-1-git-send-email-zheyuma97@gmail.com/

> diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
> index ad9029ae6848..348ed5412544 100644
> --- a/drivers/net/ethernet/sun/sunhme.c
> +++ b/drivers/net/ethernet/sun/sunhme.c
> @@ -3146,7 +3146,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
>  	if (err) {
>  		printk(KERN_ERR "happymeal(PCI): Cannot register net device, "
>  		       "aborting.\n");
> -		goto err_out_iounmap;
> +		goto err_out_free_dma;
>  	}
>  
>  	pci_set_drvdata(pdev, hp);
> @@ -3179,6 +3179,10 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
>  
>  	return 0;
>  
> +err_out_free_dma:
> +	dma_free_coherent(hp->dma_dev, PAGE_SIZE,
> +			  hp->happy_block, hp->hblock_dvma);
> +
>  err_out_iounmap:
>  	iounmap(hp->gregs);
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index ad9029ae6848..348ed5412544 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -3146,7 +3146,7 @@  static int happy_meal_pci_probe(struct pci_dev *pdev,
 	if (err) {
 		printk(KERN_ERR "happymeal(PCI): Cannot register net device, "
 		       "aborting.\n");
-		goto err_out_iounmap;
+		goto err_out_free_dma;
 	}
 
 	pci_set_drvdata(pdev, hp);
@@ -3179,6 +3179,10 @@  static int happy_meal_pci_probe(struct pci_dev *pdev,
 
 	return 0;
 
+err_out_free_dma:
+	dma_free_coherent(hp->dma_dev, PAGE_SIZE,
+			  hp->happy_block, hp->hblock_dvma);
+
 err_out_iounmap:
 	iounmap(hp->gregs);