netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath10k: Fix error handling in ath10k_setup_msa_resources
@ 2022-03-08  7:02 Miaoqian Lin
  2022-03-09  0:05 ` Jeff Johnson
  2022-03-10 15:52 ` Kalle Valo
  0 siblings, 2 replies; 4+ messages in thread
From: Miaoqian Lin @ 2022-03-08  7:02 UTC (permalink / raw)
  To: Kalle Valo, David S. Miller, Jakub Kicinski, Rakesh Pillai,
	ath10k, linux-wireless, netdev, linux-kernel
  Cc: linmq006

The device_node pointer is returned by of_parse_phandle()  with refcount
incremented. We should use of_node_put() on it when done.

This function only calls of_node_put() in the regular path.
And it will cause refcount leak in error path.

Fixes: 727fec790ead ("ath10k: Setup the msa resources before qmi init")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/net/wireless/ath/ath10k/snoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c
index 9513ab696fff..f79dd9a71690 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -1556,11 +1556,11 @@ static int ath10k_setup_msa_resources(struct ath10k *ar, u32 msa_size)
 	node = of_parse_phandle(dev->of_node, "memory-region", 0);
 	if (node) {
 		ret = of_address_to_resource(node, 0, &r);
+		of_node_put(node);
 		if (ret) {
 			dev_err(dev, "failed to resolve msa fixed region\n");
 			return ret;
 		}
-		of_node_put(node);
 
 		ar->msa.paddr = r.start;
 		ar->msa.mem_size = resource_size(&r);
-- 
2.17.1


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

* Re: [PATCH] ath10k: Fix error handling in ath10k_setup_msa_resources
  2022-03-08  7:02 [PATCH] ath10k: Fix error handling in ath10k_setup_msa_resources Miaoqian Lin
@ 2022-03-09  0:05 ` Jeff Johnson
  2022-03-09  7:23   ` Kalle Valo
  2022-03-10 15:52 ` Kalle Valo
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff Johnson @ 2022-03-09  0:05 UTC (permalink / raw)
  To: Miaoqian Lin, Kalle Valo, David S. Miller, Jakub Kicinski,
	Rakesh Pillai, ath10k, linux-wireless, netdev, linux-kernel

On 3/7/2022 11:02 PM, Miaoqian Lin wrote:
> The device_node pointer is returned by of_parse_phandle()  with refcount

Kalle, can you fix this nit when you apply?  remove extra space after ()

> incremented. We should use of_node_put() on it when done.
> 
> This function only calls of_node_put() in the regular path.
> And it will cause refcount leak in error path.
> 
> Fixes: 727fec790ead ("ath10k: Setup the msa resources before qmi init")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>   drivers/net/wireless/ath/ath10k/snoc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c
> index 9513ab696fff..f79dd9a71690 100644
> --- a/drivers/net/wireless/ath/ath10k/snoc.c
> +++ b/drivers/net/wireless/ath/ath10k/snoc.c
> @@ -1556,11 +1556,11 @@ static int ath10k_setup_msa_resources(struct ath10k *ar, u32 msa_size)
>   	node = of_parse_phandle(dev->of_node, "memory-region", 0);
>   	if (node) {
>   		ret = of_address_to_resource(node, 0, &r);
> +		of_node_put(node);
>   		if (ret) {
>   			dev_err(dev, "failed to resolve msa fixed region\n");
>   			return ret;
>   		}
> -		of_node_put(node);
>   
>   		ar->msa.paddr = r.start;
>   		ar->msa.mem_size = resource_size(&r);

Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>

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

* Re: [PATCH] ath10k: Fix error handling in ath10k_setup_msa_resources
  2022-03-09  0:05 ` Jeff Johnson
@ 2022-03-09  7:23   ` Kalle Valo
  0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2022-03-09  7:23 UTC (permalink / raw)
  To: Jeff Johnson
  Cc: Miaoqian Lin, David S. Miller, Jakub Kicinski, Rakesh Pillai,
	ath10k, linux-wireless, netdev, linux-kernel

Jeff Johnson <quic_jjohnson@quicinc.com> writes:

> On 3/7/2022 11:02 PM, Miaoqian Lin wrote:
>> The device_node pointer is returned by of_parse_phandle()  with refcount
>
> Kalle, can you fix this nit when you apply?  remove extra space after ()

Will do, thanks.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

* Re: [PATCH] ath10k: Fix error handling in ath10k_setup_msa_resources
  2022-03-08  7:02 [PATCH] ath10k: Fix error handling in ath10k_setup_msa_resources Miaoqian Lin
  2022-03-09  0:05 ` Jeff Johnson
@ 2022-03-10 15:52 ` Kalle Valo
  1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2022-03-10 15:52 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: David S. Miller, Jakub Kicinski, Rakesh Pillai, ath10k,
	linux-wireless, netdev, linux-kernel, linmq006

Miaoqian Lin <linmq006@gmail.com> wrote:

> The device_node pointer is returned by of_parse_phandle() with refcount
> incremented. We should use of_node_put() on it when done.
> 
> This function only calls of_node_put() in the regular path.
> And it will cause refcount leak in error path.
> 
> Fixes: 727fec790ead ("ath10k: Setup the msa resources before qmi init")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

Patch applied to ath-next branch of ath.git, thanks.

9747a78d5f75 ath10k: Fix error handling in ath10k_setup_msa_resources

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20220308070238.19295-1-linmq006@gmail.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2022-03-10 15:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-08  7:02 [PATCH] ath10k: Fix error handling in ath10k_setup_msa_resources Miaoqian Lin
2022-03-09  0:05 ` Jeff Johnson
2022-03-09  7:23   ` Kalle Valo
2022-03-10 15:52 ` Kalle Valo

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