diff mbox

[06/15] ethernet: hisilicon: hns: hns_dsaf_mac: add missing of_node_put after calling of_parse_phandle

Message ID 1469586048-15697-7-git-send-email-peter.chen@nxp.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Peter Chen July 27, 2016, 2:20 a.m. UTC
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Yisen.Zhuang(Zhuangyuzeng) July 28, 2016, 12:38 a.m. UTC | #1
在 2016/7/27 10:20, Peter Chen 写道:
> of_node_put needs to be called when the device node which is got
> from of_parse_phandle has finished using.
> 
> Signed-off-by: Peter Chen <peter.chen@nxp.com>
> ---
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> index 3fb87e2..18d72ea 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> @@ -786,6 +786,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
>  		np = of_parse_phandle(mac_cb->dev->of_node, "phy-handle",
>  				      mac_cb->mac_id);
>  		mac_cb->phy_dev = of_phy_find_device(np);
> +		of_node_put(np);
>  		if (mac_cb->phy_dev) {
>  			/* refcount is held by of_phy_find_device()
>  			 * if the phy_dev is found

np is accessed in case of of_phy_find_device() returns a no null value, so it has to be
moved after the dev_dbg log.

> @@ -804,6 +805,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
>  		np = of_parse_phandle(to_of_node(mac_cb->fw_port),
>  				      "phy-handle", 0);
>  		mac_cb->phy_dev = of_phy_find_device(np);
> +		of_node_put(np);
>  		if (mac_cb->phy_dev) {
>  			/* refcount is held by of_phy_find_device()
>  			 * if the phy_dev is found

np is accessed in case of of_phy_find_device() returns a no null value, so it has to be
moved after the dev_dbg log.

Thanks,

Yisen

> @@ -813,9 +815,10 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
>  				mac_cb->mac_id, np->name);
>  		}
>  
> -		syscon = syscon_node_to_regmap(
> -				of_parse_phandle(to_of_node(mac_cb->fw_port),
> -						 "serdes-syscon", 0));
> +		np = of_parse_phandle(to_of_node(mac_cb->fw_port),
> +					"serdes-syscon", 0);
> +		syscon = syscon_node_to_regmap(np);
> +		of_node_put(np);
>  		if (IS_ERR_OR_NULL(syscon)) {
>  			dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
>  			return -EINVAL;
>
Peter Chen July 28, 2016, 3:43 a.m. UTC | #2
>在 2016/7/27 10:20, Peter Chen 写道:

>> of_node_put needs to be called when the device node which is got from

>> of_parse_phandle has finished using.

>>

>> Signed-off-by: Peter Chen <peter.chen@nxp.com>

>> ---

>>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 9 ++++++---

>>  1 file changed, 6 insertions(+), 3 deletions(-)

>>

>> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c

>> b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c

>> index 3fb87e2..18d72ea 100644

>> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c

>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c

>> @@ -786,6 +786,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)

>>  		np = of_parse_phandle(mac_cb->dev->of_node, "phy-handle",

>>  				      mac_cb->mac_id);

>>  		mac_cb->phy_dev = of_phy_find_device(np);

>> +		of_node_put(np);

>>  		if (mac_cb->phy_dev) {

>>  			/* refcount is held by of_phy_find_device()

>>  			 * if the phy_dev is found

>

>np is accessed in case of of_phy_find_device() returns a no null value, so it has to be

>moved after the dev_dbg log.

>

>> @@ -804,6 +805,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)

>>  		np = of_parse_phandle(to_of_node(mac_cb->fw_port),

>>  				      "phy-handle", 0);

>>  		mac_cb->phy_dev = of_phy_find_device(np);

>> +		of_node_put(np);

>>  		if (mac_cb->phy_dev) {

>>  			/* refcount is held by of_phy_find_device()

>>  			 * if the phy_dev is found

>

>np is accessed in case of of_phy_find_device() returns a no null value, so it has to be

>moved after the dev_dbg log.

>


Thanks, I will change them.

Peter
diff mbox

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 3fb87e2..18d72ea 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -786,6 +786,7 @@  static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
 		np = of_parse_phandle(mac_cb->dev->of_node, "phy-handle",
 				      mac_cb->mac_id);
 		mac_cb->phy_dev = of_phy_find_device(np);
+		of_node_put(np);
 		if (mac_cb->phy_dev) {
 			/* refcount is held by of_phy_find_device()
 			 * if the phy_dev is found
@@ -804,6 +805,7 @@  static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
 		np = of_parse_phandle(to_of_node(mac_cb->fw_port),
 				      "phy-handle", 0);
 		mac_cb->phy_dev = of_phy_find_device(np);
+		of_node_put(np);
 		if (mac_cb->phy_dev) {
 			/* refcount is held by of_phy_find_device()
 			 * if the phy_dev is found
@@ -813,9 +815,10 @@  static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
 				mac_cb->mac_id, np->name);
 		}
 
-		syscon = syscon_node_to_regmap(
-				of_parse_phandle(to_of_node(mac_cb->fw_port),
-						 "serdes-syscon", 0));
+		np = of_parse_phandle(to_of_node(mac_cb->fw_port),
+					"serdes-syscon", 0);
+		syscon = syscon_node_to_regmap(np);
+		of_node_put(np);
 		if (IS_ERR_OR_NULL(syscon)) {
 			dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
 			return -EINVAL;