Skip to contentSkip to conversation

ath11k: do not return random value

PATCH In review Michael Straube 3 participants 4 messages Apr 4, 2022

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

PATCH 1/1 ath11k: do not return random value

Function ath11k_qmi_assign_target_mem_chunk() returns a random value if of_parse_phandle() fails because the return variable ret is not initialized before calling of_parse_phandle(). Return -EINVAL to avoid possibly returning 0, which would be wrong here.

Issue found by smatch.

---
 drivers/net/wireless/ath/ath11k/qmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/qmi.c +1 -1
index 65d3c6ba35ae..81b2304b1fde 100644
@@ -1932,7 +1932,7 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab)
 			if (!hremote_node) {
 				ath11k_dbg(ab, ATH11K_DBG_QMI,
 					   "qmi fail to get hremote_node\n");
-				return ret;
+				return -EINVAL;
 			}
 
 			ret = of_address_to_resource(hremote_node, 0, &res);
Signature · 1 line
2.35.1
#1 lore raw
Quoted 27 lines · Michael Straube

Function ath11k_qmi_assign_target_mem_chunk() returns a random value if of_parse_phandle() fails because the return variable ret is not initialized before calling of_parse_phandle(). Return -EINVAL to avoid possibly returning 0, which would be wrong here.

Issue found by smatch.

---
 drivers/net/wireless/ath/ath11k/qmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/qmi.c +1 -2
index 65d3c6ba35ae..81b2304b1fde 100644
@@ -1932,7 +1932,7 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab)
                        if (!hremote_node) {
                                ath11k_dbg(ab, ATH11K_DBG_QMI,
                                           "qmi fail to get hremote_node\n");
-                               return ret;
+                               return -EINVAL;
                        }
 
                        ret = of_address_to_resource(hremote_node, 0, &res);
--
Quoted 1 line

2.35.1

Hi Michael,
This is already solved in ath-next and 5.18-rc1:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/net/wireless/ath/ath11k/qmi.c?h=v5.18-rc1&id=c9b41832dc080fa59bad597de94865b3ea2d5bab

Regards,
Robert

Quoted 6 lines

--
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k

Signature · 12 lines
Robert Marko
Staff Embedded Linux Engineer
Sartura Ltd.
Lendavska ulica 16a
10000 Zagreb, Croatia
Email: [email protected]
Web: www.sartura.hr

-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#2 lore raw
Quoted 26 lines · Robert Marko
Quoted 25 lines · Michael Straube

Function ath11k_qmi_assign_target_mem_chunk() returns a random value if of_parse_phandle() fails because the return variable ret is not initialized before calling of_parse_phandle(). Return -EINVAL to avoid possibly returning 0, which would be wrong here.

Issue found by smatch.

---
  drivers/net/wireless/ath/ath11k/qmi.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/qmi.c +1 -1
index 65d3c6ba35ae..81b2304b1fde 100644
@@ -1932,7 +1932,7 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab)
                         if (!hremote_node) {
                                 ath11k_dbg(ab, ATH11K_DBG_QMI,
                                            "qmi fail to get hremote_node\n");
-                               return ret;
+                               return -EINVAL;
                         }
 
Quoted 8 lines
Quoted 3 lines
drivers/net/wireless/ath/ath11k/qmi.c +0 -1
                         ret = of_address_to_resource(hremote_node, 0, &res);
--

2.35.1

Hi Michael,
This is already solved in ath-next and 5.18-rc1:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/net/wireless/ath/ath11k/qmi.c?h=v5.18-rc1&id=c9b41832dc080fa59bad597de94865b3ea2d5bab

Hi Robert,

Ah ok, then I worked with the wrong tree (wireless-drivers-next). Sorry for the noise.

regards,
Michael

Signature · 3 lines
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#3 lore raw
Quoted 36 lines · Michael Straube
Quoted 26 lines · Robert Marko
Quoted 25 lines · Michael Straube

Function ath11k_qmi_assign_target_mem_chunk() returns a random value if of_parse_phandle() fails because the return variable ret is not initialized before calling of_parse_phandle(). Return -EINVAL to avoid possibly returning 0, which would be wrong here.

Issue found by smatch.

---
  drivers/net/wireless/ath/ath11k/qmi.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/qmi.c +1 -1
index 65d3c6ba35ae..81b2304b1fde 100644
@@ -1932,7 +1932,7 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab)
                         if (!hremote_node) {
                                 ath11k_dbg(ab, ATH11K_DBG_QMI,
                                            "qmi fail to get hremote_node\n");
-                               return ret;
+                               return -EINVAL;
                         }
 
Quoted 8 lines
Quoted 3 lines
drivers/net/wireless/ath/ath11k/qmi.c +0 -1
                         ret = of_address_to_resource(hremote_node, 0, &res);
--

2.35.1

Hi Michael,
This is already solved in ath-next and 5.18-rc1:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/net/wireless/ath/ath11k/qmi.c?h=v5.18-rc1&id=c9b41832dc080fa59bad597de94865b3ea2d5bab

Quoted 4 lines

Hi Robert,

Ah ok, then I worked with the wrong tree (wireless-drivers-next). Sorry for the noise.

wireless-drivers[-next] and mac80211[-next] trees are not in use anymore, we switched to using a common wireless and wireless-next trees:

https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git/

https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git/

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

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

-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k