diff mbox series

ethernet: fman: add missing put_device() call in mac_probe()

Message ID 1638881761-3262-1-git-send-email-wangqing@vivo.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series ethernet: fman: add missing put_device() call in mac_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, 40 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

王擎 Dec. 7, 2021, 12:56 p.m. UTC
From: Wang Qing <wangqing@vivo.com>

of_find_device_by_node() takes a reference to the embedded struct device 
which needs to be dropped when error return.

Add a jump target to fix the exception handling for this 
function implementation.

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 drivers/net/ethernet/freescale/fman/mac.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Jakub Kicinski Dec. 9, 2021, 2:29 a.m. UTC | #1
On Tue,  7 Dec 2021 04:56:00 -0800 Qing Wang wrote:
> From: Wang Qing <wangqing@vivo.com>
> 
> of_find_device_by_node() takes a reference to the embedded struct device 
> which needs to be dropped when error return.
> 
> Add a jump target to fix the exception handling for this 
> function implementation.
> 
> Signed-off-by: Wang Qing <wangqing@vivo.com>

The entire mac_dev->port[] handling seems entirely pointless and leaky. 
Nothing ever reads the mac_dev->port array. We should remove it
completely.

> diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
> index d9fc5c4..5180121
> --- a/drivers/net/ethernet/freescale/fman/mac.c
> +++ b/drivers/net/ethernet/freescale/fman/mac.c
> @@ -668,7 +668,7 @@ static int mac_probe(struct platform_device *_of_dev)
>  	if (err) {
>  		dev_err(dev, "failed to read cell-index for %pOF\n", dev_node);
>  		err = -EINVAL;
> -		goto _return_of_node_put;
> +		goto _return_of_put_device;
>  	}
>  	/* cell-index 0 => FMan id 1 */
>  	fman_id = (u8)(val + 1);
> @@ -677,7 +677,7 @@ static int mac_probe(struct platform_device *_of_dev)
>  	if (!priv->fman) {
>  		dev_err(dev, "fman_bind(%pOF) failed\n", dev_node);
>  		err = -ENODEV;
> -		goto _return_of_node_put;
> +		goto _return_of_put_device;
>  	}
>  
>  	of_node_put(dev_node);
> @@ -758,7 +758,7 @@ static int mac_probe(struct platform_device *_of_dev)
>  			dev_err(dev, "of_find_device_by_node(%pOF) failed\n",
>  				dev_node);
>  			err = -EINVAL;
> -			goto _return_of_node_put;
> +			goto _return_of_put_device;
>  		}
>  
>  		mac_dev->port[i] = fman_port_bind(&of_dev->dev);
> @@ -766,7 +766,7 @@ static int mac_probe(struct platform_device *_of_dev)
>  			dev_err(dev, "dev_get_drvdata(%pOF) failed\n",
>  				dev_node);
>  			err = -EINVAL;
> -			goto _return_of_node_put;
> +			goto _return_of_put_device;
>  		}
>  		of_node_put(dev_node);
>  	}
> @@ -863,6 +863,8 @@ static int mac_probe(struct platform_device *_of_dev)
>  
>  	goto _return;
>  
> +_return_of_put_device:
> +	put_device(&of_dev->dev);
>  _return_of_node_put:
>  	of_node_put(dev_node);
>  _return_of_get_parent:
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index d9fc5c4..5180121
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -668,7 +668,7 @@  static int mac_probe(struct platform_device *_of_dev)
 	if (err) {
 		dev_err(dev, "failed to read cell-index for %pOF\n", dev_node);
 		err = -EINVAL;
-		goto _return_of_node_put;
+		goto _return_of_put_device;
 	}
 	/* cell-index 0 => FMan id 1 */
 	fman_id = (u8)(val + 1);
@@ -677,7 +677,7 @@  static int mac_probe(struct platform_device *_of_dev)
 	if (!priv->fman) {
 		dev_err(dev, "fman_bind(%pOF) failed\n", dev_node);
 		err = -ENODEV;
-		goto _return_of_node_put;
+		goto _return_of_put_device;
 	}
 
 	of_node_put(dev_node);
@@ -758,7 +758,7 @@  static int mac_probe(struct platform_device *_of_dev)
 			dev_err(dev, "of_find_device_by_node(%pOF) failed\n",
 				dev_node);
 			err = -EINVAL;
-			goto _return_of_node_put;
+			goto _return_of_put_device;
 		}
 
 		mac_dev->port[i] = fman_port_bind(&of_dev->dev);
@@ -766,7 +766,7 @@  static int mac_probe(struct platform_device *_of_dev)
 			dev_err(dev, "dev_get_drvdata(%pOF) failed\n",
 				dev_node);
 			err = -EINVAL;
-			goto _return_of_node_put;
+			goto _return_of_put_device;
 		}
 		of_node_put(dev_node);
 	}
@@ -863,6 +863,8 @@  static int mac_probe(struct platform_device *_of_dev)
 
 	goto _return;
 
+_return_of_put_device:
+	put_device(&of_dev->dev);
 _return_of_node_put:
 	of_node_put(dev_node);
 _return_of_get_parent: