staging: rtl8712: r8712_joinbss_cmd(): Change return values and type [Linux 5.3]

This Linux kernel change "staging: rtl8712: r8712_joinbss_cmd(): Change return values and type" is included in the Linux 5.3 release. This change is authored by Nishka Dasgupta <nishkadg.linux [at] gmail.com> on Thu Jun 20 17:22:58 2019 +0530. The commit for this change in Linux stable tree is 36f484e (patch).

staging: rtl8712: r8712_joinbss_cmd(): Change return values and type

Change return values of function r8712_joinbss_cmd from _SUCCESS/_FAIL
to 0/-ENOMEM respectively.
Change return type from u8 to int to accommodate return of -ENOMEM.

Similarly, change the return values (_SUCCESS to 0 and _FAIL to -ENOMEM
or -EINVAL) and type (sint to int) of the call site of r8712_joinbss_cmd,
r8712_select_and_join_from_scan, as one of the branches of
r8712_select_and_join_from_scan directly returns the return value of
r8712_joinbss_cmd.

Modify the call sites of r8712_select_and_join_from_scan to check for
0 instead of _SUCCESS.

Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

There are 22 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/staging/rtl8712/rtl871x_cmd.c       | 6 +++---
 drivers/staging/rtl8712/rtl871x_cmd.h       | 4 ++--
 drivers/staging/rtl8712/rtl871x_ioctl_set.c | 2 +-
 drivers/staging/rtl8712/rtl871x_mlme.c      | 8 +++-----
 drivers/staging/rtl8712/rtl871x_mlme.h      | 2 +-
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c
index 01146d9..9cc6a37 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -434,7 +434,7 @@ int r8712_createbss_cmd(struct _adapter *padapter)
    return 0;
 }

-u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
+int r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
 {
    struct wlan_bssid_ex *psecnetwork;
    struct cmd_obj      *pcmd;
@@ -449,7 +449,7 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
    padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK);
    pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
    if (!pcmd)
-       return _FAIL;
+       return -ENOMEM;

    /* for hidden ap to set fw_state here */
    if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE) !=
@@ -566,7 +566,7 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
    pcmd->rsp = NULL;
    pcmd->rspsz = 0;
    r8712_enqueue_cmd(pcmdpriv, pcmd);
-   return _SUCCESS;
+   return 0;
 }

 u8 r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h
index 6ea1baf..7d4da8e 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.h
+++ b/drivers/staging/rtl8712/rtl871x_cmd.h
@@ -714,8 +714,8 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
            struct ndis_802_11_ssid *pssid);
 int r8712_createbss_cmd(struct _adapter *padapter);
 u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key);
-u8 r8712_joinbss_cmd(struct _adapter *padapter,
-            struct wlan_network *pnetwork);
+int r8712_joinbss_cmd(struct _adapter *padapter,
+             struct wlan_network *pnetwork);
 u8 r8712_disassoc_cmd(struct _adapter *padapter);
 u8 r8712_setopmode_cmd(struct _adapter *padapter,
         enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
index d0274c6..f3c0a93 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
@@ -66,7 +66,7 @@ static u8 do_join(struct _adapter *padapter)
    }

    ret = r8712_select_and_join_from_scan(pmlmepriv);
-   if (ret == _SUCCESS) {
+   if (!ret) {
        mod_timer(&pmlmepriv->assoc_timer,
              jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
    } else {
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c
index f6ba3e8..b260c29 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.c
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -548,8 +548,7 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf)
            if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
                set_fwstate(pmlmepriv, _FW_UNDER_LINKING);

-               if (r8712_select_and_join_from_scan(pmlmepriv)
-                   == _SUCCESS) {
+               if (!r8712_select_and_join_from_scan(pmlmepriv)) {
                    mod_timer(&pmlmepriv->assoc_timer, jiffies +
                          msecs_to_jiffies(MAX_JOIN_TIMEOUT));
                } else {
@@ -574,8 +573,7 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf)
        } else {
            pmlmepriv->to_join = false;
            set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
-           if (r8712_select_and_join_from_scan(pmlmepriv) ==
-               _SUCCESS)
+           if (!r8712_select_and_join_from_scan(pmlmepriv))
                mod_timer(&pmlmepriv->assoc_timer, jiffies +
                      msecs_to_jiffies(MAX_JOIN_TIMEOUT));
            else
@@ -1106,7 +1104,7 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv)
                pnetwork = pnetwork_max_rssi;
                goto ask_for_joinbss;
            }
-           return _FAIL;
+           return -EINVAL;
        }
        pnetwork = container_of(pmlmepriv->pscanned,
                    struct wlan_network, list);
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.h b/drivers/staging/rtl8712/rtl871x_mlme.h
index 8a54181..9e83431 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.h
+++ b/drivers/staging/rtl8712/rtl871x_mlme.h
@@ -172,7 +172,7 @@ static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv,
 void r8712_free_network_queue(struct _adapter *adapter);
 int r8712_init_mlme_priv(struct _adapter *adapter);
 void r8712_free_mlme_priv(struct mlme_priv *pmlmepriv);
-sint r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv);
+int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv);
 sint r8712_set_key(struct _adapter *adapter,
           struct security_priv *psecuritypriv, sint keyid);
 sint r8712_set_auth(struct _adapter *adapter,

Leave a Reply

Your email address will not be published. Required fields are marked *