linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dpaa2-mac: add missing of_node_put() in dpaa2_mac_get_node()
@ 2022-04-28 10:01 Yang Yingliang
  2022-04-30  2:29 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Yang Yingliang @ 2022-04-28 10:01 UTC (permalink / raw)
  To: linux-kernel, netdev; +Cc: ioana.ciornei, davem, kuba, robert-ionut.alexa

Add missing of_node_put() in error path in dpaa2_mac_get_node().

Fixes: 5b1e38c0792c ("dpaa2-mac: bail if the dpmacs fwnode is not found")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index c48811d3bcd5..a91446685526 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -108,8 +108,11 @@ static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
 		return ERR_PTR(-EPROBE_DEFER);
 	}
 
-	if (!parent)
+	if (!parent) {
+		if (dpmacs)
+			of_node_put(dpmacs);
 		return NULL;
+	}
 
 	fwnode_for_each_child_node(parent, child) {
 		err = -EINVAL;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: dpaa2-mac: add missing of_node_put() in dpaa2_mac_get_node()
  2022-04-28 10:01 [PATCH] net: dpaa2-mac: add missing of_node_put() in dpaa2_mac_get_node() Yang Yingliang
@ 2022-04-30  2:29 ` Jakub Kicinski
  2022-05-05  1:30   ` Yang Yingliang
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2022-04-30  2:29 UTC (permalink / raw)
  To: Yang Yingliang
  Cc: linux-kernel, netdev, ioana.ciornei, davem, robert-ionut.alexa

On Thu, 28 Apr 2022 18:01:27 +0800 Yang Yingliang wrote:
> Add missing of_node_put() in error path in dpaa2_mac_get_node().
> 
> Fixes: 5b1e38c0792c ("dpaa2-mac: bail if the dpmacs fwnode is not found")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
> index c48811d3bcd5..a91446685526 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
> @@ -108,8 +108,11 @@ static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
>  		return ERR_PTR(-EPROBE_DEFER);
>  	}
>  
> -	if (!parent)
> +	if (!parent) {
> +		if (dpmacs)
> +			of_node_put(dpmacs);

of_node_put() accepts NULL. I know this because unlike you I did 
at least the bare minimum looking at the surrounding code and saw 
other places not checking if it's NULL.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: dpaa2-mac: add missing of_node_put() in dpaa2_mac_get_node()
  2022-04-30  2:29 ` Jakub Kicinski
@ 2022-05-05  1:30   ` Yang Yingliang
  0 siblings, 0 replies; 3+ messages in thread
From: Yang Yingliang @ 2022-05-05  1:30 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: linux-kernel, netdev, ioana.ciornei, davem, robert-ionut.alexa

Hi,

On 2022/4/30 10:29, Jakub Kicinski wrote:
> On Thu, 28 Apr 2022 18:01:27 +0800 Yang Yingliang wrote:
>> Add missing of_node_put() in error path in dpaa2_mac_get_node().
>>
>> Fixes: 5b1e38c0792c ("dpaa2-mac: bail if the dpmacs fwnode is not found")
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>> ---
>>   drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
>> index c48811d3bcd5..a91446685526 100644
>> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
>> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
>> @@ -108,8 +108,11 @@ static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
>>   		return ERR_PTR(-EPROBE_DEFER);
>>   	}
>>   
>> -	if (!parent)
>> +	if (!parent) {
>> +		if (dpmacs)
>> +			of_node_put(dpmacs);
> of_node_put() accepts NULL. I know this because unlike you I did
> at least the bare minimum looking at the surrounding code and saw
> other places not checking if it's NULL.
I missed that, I will send a v2 later.

Thanks,
Yang
> .

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-05  1:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 10:01 [PATCH] net: dpaa2-mac: add missing of_node_put() in dpaa2_mac_get_node() Yang Yingliang
2022-04-30  2:29 ` Jakub Kicinski
2022-05-05  1:30   ` Yang Yingliang

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).