diff mbox series

[1/3] wifi: brcmfmac: handle possible WOWL configuration error

Message ID 20230607161611.85106-1-dmantipov@yandex.ru
State New
Headers show
Series [1/3] wifi: brcmfmac: handle possible WOWL configuration error | expand

Commit Message

Dmitry Antipov June 7, 2023, 4:16 p.m. UTC
Convert 'brcmf_configure_wowl()' to return 's32' which may be
an error raised by 'brcmf_fil_iovar_data_set()', pass the
value to 'brcmf_cfg80211_suspend()' and adjust related code.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c    | 32 +++++++++++--------
 1 file changed, 19 insertions(+), 13 deletions(-)

Comments

Kalle Valo June 15, 2023, 7:32 a.m. UTC | #1
Dmitry Antipov <dmantipov@yandex.ru> wrote:

> Convert 'brcmf_configure_wowl()' to return 's32' which may be
> an error raised by 'brcmf_fil_iovar_data_set()', pass the
> value to 'brcmf_cfg80211_suspend()' and adjust related code.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Using s32 for an error value is strange for me, usually we use int.

This patchset feels like random cleanup which makes me wary. How are these 3
patches tested?
Dmitry Antipov June 15, 2023, 8:30 a.m. UTC | #2
On 6/15/23 10:32, Kalle Valo wrote:

> This patchset feels like random cleanup which makes me wary

Note series v2 was posted a few days ago.

> How are these 3 patches tested?

It was quickly checked to not break (cheap noname) BCM43236-based
USB Wi-Fi adapter I occasionally have.

Dmitry
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index de8a2e27f49c..5a0b32322b4f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -4175,12 +4175,13 @@  static s32 brcmf_cfg80211_resume(struct wiphy *wiphy)
 	return 0;
 }
 
-static void brcmf_configure_wowl(struct brcmf_cfg80211_info *cfg,
-				 struct brcmf_if *ifp,
-				 struct cfg80211_wowlan *wowl)
+static s32 brcmf_configure_wowl(struct brcmf_cfg80211_info *cfg,
+				struct brcmf_if *ifp,
+				struct cfg80211_wowlan *wowl)
 {
 	u32 wowl_config;
 	struct brcmf_wowl_wakeind_le wowl_wakeind;
+	s32 err = 0;
 	u32 i;
 
 	brcmf_dbg(TRACE, "Suspend, wowl config.\n");
@@ -4223,12 +4224,15 @@  static void brcmf_configure_wowl(struct brcmf_cfg80211_info *cfg,
 		wowl_config |= BRCMF_WOWL_UNASSOC;
 
 	memcpy(&wowl_wakeind, "clear", 6);
-	brcmf_fil_iovar_data_set(ifp, "wowl_wakeind", &wowl_wakeind,
-				 sizeof(wowl_wakeind));
-	brcmf_fil_iovar_int_set(ifp, "wowl", wowl_config);
-	brcmf_fil_iovar_int_set(ifp, "wowl_activate", 1);
-	brcmf_bus_wowl_config(cfg->pub->bus_if, true);
-	cfg->wowl.active = true;
+	err = brcmf_fil_iovar_data_set(ifp, "wowl_wakeind", &wowl_wakeind,
+				       sizeof(wowl_wakeind));
+	if (err == 0) {
+		brcmf_fil_iovar_int_set(ifp, "wowl", wowl_config);
+		brcmf_fil_iovar_int_set(ifp, "wowl_activate", 1);
+		brcmf_bus_wowl_config(cfg->pub->bus_if, true);
+		cfg->wowl.active = true;
+	}
+	return err;
 }
 
 static int brcmf_keepalive_start(struct brcmf_if *ifp, unsigned int interval)
@@ -4256,6 +4260,7 @@  static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy,
 	struct net_device *ndev = cfg_to_ndev(cfg);
 	struct brcmf_if *ifp = netdev_priv(ndev);
 	struct brcmf_cfg80211_vif *vif;
+	s32 err = 0;
 
 	brcmf_dbg(TRACE, "Enter\n");
 
@@ -4293,18 +4298,19 @@  static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy,
 		brcmf_set_mpc(ifp, 1);
 
 	} else {
-		/* Configure WOWL paramaters */
-		brcmf_configure_wowl(cfg, ifp, wowl);
+		/* Configure WOWL parameters */
+		err = brcmf_configure_wowl(cfg, ifp, wowl);
 
 		/* Prevent disassociation due to inactivity with keep-alive */
-		brcmf_keepalive_start(ifp, 30);
+		if (err == 0)
+			brcmf_keepalive_start(ifp, 30);
 	}
 
 exit:
 	brcmf_dbg(TRACE, "Exit\n");
 	/* clear any scanning activity */
 	cfg->scan_status = 0;
-	return 0;
+	return err;
 }
 
 static s32