diff mbox

[14/15] ethernet: stmicro: stmmac: stmmac_platform: add missing of_node_put after calling of_parse_phandle

Message ID 1469586048-15697-15-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/stmicro/stmmac/stmmac_platform.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Alexandre TORGUE July 28, 2016, 7:39 a.m. UTC | #1
Hi,

On 07/27/2016 04:20 AM, Peter Chen wrote:
> 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/stmicro/stmmac/stmmac_platform.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> index f7dfc0a..8d88782 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> @@ -113,8 +113,10 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
>   		return NULL;
>
>   	axi = kzalloc(sizeof(*axi), GFP_KERNEL);
> -	if (!axi)
> +	if (!axi) {
> +		of_node_put(np);
>   		return ERR_PTR(-ENOMEM);
> +	}
>
>   	axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
>   	axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
> @@ -127,6 +129,7 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
>   	of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt);
>   	of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt);
>   	of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
> +	of_node_put(np);
>
>   	return axi;
>   }
>

I agree with the modification inside stmmac_axi. I just have a question 
about np = pdev->dev.of_node inside stmmac_probe_config_dt (same file). 
We could add a "of_node_put(np)" just before "return plat" ?

Regards

alex
Peter Chen July 28, 2016, 9:30 a.m. UTC | #2
>Hi,
>
>On 07/27/2016 04:20 AM, Peter Chen wrote:
>> 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/stmicro/stmmac/stmmac_platform.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> index f7dfc0a..8d88782 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> @@ -113,8 +113,10 @@ static struct stmmac_axi *stmmac_axi_setup(struct
>platform_device *pdev)
>>   		return NULL;
>>
>>   	axi = kzalloc(sizeof(*axi), GFP_KERNEL);
>> -	if (!axi)
>> +	if (!axi) {
>> +		of_node_put(np);
>>   		return ERR_PTR(-ENOMEM);
>> +	}
>>
>>   	axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
>>   	axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm"); @@
>> -127,6 +129,7 @@ static struct stmmac_axi *stmmac_axi_setup(struct
>platform_device *pdev)
>>   	of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt);
>>   	of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt);
>>   	of_property_read_u32_array(np, "snps,blen", axi->axi_blen,
>> AXI_BLEN);
>> +	of_node_put(np);
>>
>>   	return axi;
>>   }
>>
>
>I agree with the modification inside stmmac_axi. I just have a question about np =
>pdev->dev.of_node inside stmmac_probe_config_dt (same file).
>We could add a "of_node_put(np)" just before "return plat" ?
>

Yes, you remind me there is still one node need to be put (should be plat->phy_node),
except for changing node name at error path, how about calling of_node_put(plat->phy_node) at
stmmac_release after phy is disconnected?

Peter
diff mbox

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index f7dfc0a..8d88782 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -113,8 +113,10 @@  static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
 		return NULL;
 
 	axi = kzalloc(sizeof(*axi), GFP_KERNEL);
-	if (!axi)
+	if (!axi) {
+		of_node_put(np);
 		return ERR_PTR(-ENOMEM);
+	}
 
 	axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
 	axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
@@ -127,6 +129,7 @@  static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
 	of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt);
 	of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt);
 	of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
+	of_node_put(np);
 
 	return axi;
 }