Skip to contentSkip to conversation

ath10k: Fix error handling in ath10k_setup_msa_resources

PATCH In review Miaoqian Lin 3 participants 4 messages Mar 8, 2022 – Mar 10, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath10k: Fix error handling in ath10k_setup_msa_resources

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")
---
 drivers/net/wireless/ath/ath10k/snoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/snoc.c +1 -1
index 9513ab696fff..f79dd9a71690 100644
@@ -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);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Miaoqian Lin

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

Quoted 18 lines

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")
---
  drivers/net/wireless/ath/ath10k/snoc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/snoc.c +0 -0
index 9513ab696fff..f79dd9a71690 100644
@@ -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) {

drivers/net/wireless/ath/ath10k/snoc.c static int ath10k_setup_msa_resources(struct ath10k *ar, u32 msa_size) · line 1566

Quoted 10 lines
drivers/net/wireless/ath/ath10k/snoc.c +1 -1
  		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);

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

#2 lore raw
Quoted 4 lines · Jeff Johnson
Quoted 1 line · Miaoqian Lin

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.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#3 lore raw
In reply to Miaoqian Lin
Quoted 10 lines · Miaoqian Lin

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

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

9747a78d5f75 ath10k: Fix error handling in ath10k_setup_msa_resources

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

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