* [PATCH] rndis_wlan: tighten check of rndis_query_oid return
@ 2020-08-11 14:02 trix
2020-08-18 12:53 ` Kalle Valo
0 siblings, 1 reply; 2+ messages in thread
From: trix @ 2020-08-11 14:02 UTC (permalink / raw)
To: jussi.kivilinna, kvalo, davem, kuba
Cc: linux-wireless, netdev, linux-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
clang static analysis reports this problem
rndis_wlan.c:3147:25: warning: Assigned value is garbage or undefined
wiphy->max_num_pmkids = le32_to_cpu(caps.num_pmkids);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The setting of caps happens here, with a call to rndis_query_oid()
retval = rndis_query_oid(usbdev,
if (retval >= 0) {
Reviewing rndis_query_oid() shows that on success 0 is returned,
failure is otherwise. So the retval check is not tight enough.
So tighten the retval check. Similar problem in
rndis_wlan_get_caps().
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/net/wireless/rndis_wlan.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 8852a1832951..75b5d545b49e 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -3112,7 +3112,7 @@ static int rndis_wlan_get_caps(struct usbnet *usbdev, struct wiphy *wiphy)
retval = rndis_query_oid(usbdev,
RNDIS_OID_802_11_NETWORK_TYPES_SUPPORTED,
&networks_supported, &len);
- if (retval >= 0) {
+ if (!retval) {
n = le32_to_cpu(networks_supported.num_items);
if (n > 8)
n = 8;
@@ -3137,7 +3137,7 @@ static int rndis_wlan_get_caps(struct usbnet *usbdev, struct wiphy *wiphy)
retval = rndis_query_oid(usbdev,
RNDIS_OID_802_11_CAPABILITY,
&caps, &len);
- if (retval >= 0) {
+ if (!retval) {
netdev_dbg(usbdev->net, "RNDIS_OID_802_11_CAPABILITY -> len %d, "
"ver %d, pmkids %d, auth-encr-pairs %d\n",
le32_to_cpu(caps.length),
--
2.18.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rndis_wlan: tighten check of rndis_query_oid return
2020-08-11 14:02 [PATCH] rndis_wlan: tighten check of rndis_query_oid return trix
@ 2020-08-18 12:53 ` Kalle Valo
0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2020-08-18 12:53 UTC (permalink / raw)
To: trix
Cc: jussi.kivilinna, davem, kuba, linux-wireless, netdev,
linux-kernel, Tom Rix
trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> clang static analysis reports this problem
>
> rndis_wlan.c:3147:25: warning: Assigned value is garbage or undefined
> wiphy->max_num_pmkids = le32_to_cpu(caps.num_pmkids);
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> The setting of caps happens here, with a call to rndis_query_oid()
>
> retval = rndis_query_oid(usbdev,
> if (retval >= 0) {
>
> Reviewing rndis_query_oid() shows that on success 0 is returned,
> failure is otherwise. So the retval check is not tight enough.
> So tighten the retval check. Similar problem in
> rndis_wlan_get_caps().
>
> Signed-off-by: Tom Rix <trix@redhat.com>
Patch applied to wireless-drivers-next.git, thanks.
094dd0d73062 rndis_wlan: tighten check of rndis_query_oid return
--
https://patchwork.kernel.org/patch/11709263/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-18 12:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11 14:02 [PATCH] rndis_wlan: tighten check of rndis_query_oid return trix
2020-08-18 12:53 ` 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).