All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Ajay.Kathat@microchip.com>
To: <linux-wireless@vger.kernel.org>
Cc: <Claudiu.Beznea@microchip.com>, <Ajay.Kathat@microchip.com>
Subject: [PATCH v2 09/11] wilc1000: add 'initialized' flag check before adding an element to TX queue
Date: Thu, 16 Sep 2021 16:49:21 +0000	[thread overview]
Message-ID: <20210916164902.74629-10-ajay.kathat@microchip.com> (raw)
In-Reply-To: <20210916164902.74629-1-ajay.kathat@microchip.com>

From: Ajay Singh <ajay.kathat@microchip.com>

Add 'initialized' variable check before adding net/mgmt packet to TX queue
as safety check before passing the commands to the firmware.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
---
 drivers/net/wireless/microchip/wilc1000/cfg80211.c | 4 ++++
 drivers/net/wireless/microchip/wilc1000/wlan.c     | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
index 91a471f3b1c8..dc4bfe7be378 100644
--- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
@@ -728,6 +728,7 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev,
 {
 	struct wilc_vif *vif = netdev_priv(dev);
 	struct wilc_priv *priv = &vif->priv;
+	struct wilc *wilc = vif->wilc;
 	u32 i = 0;
 	u32 associatedsta = ~0;
 	u32 inactive_time = 0;
@@ -754,6 +755,9 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev,
 	} else if (vif->iftype == WILC_STATION_MODE) {
 		struct rf_info stats;
 
+		if (!wilc->initialized)
+			return -EBUSY;
+
 		wilc_get_statistics(vif, &stats);
 
 		sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL) |
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index de5287cd8652..ea81ef120fd1 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -427,6 +427,11 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev,
 		return 0;
 	}
 
+	if (!wilc->initialized) {
+		tx_complete_fn(tx_data, 0);
+		return 0;
+	}
+
 	tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC);
 
 	if (!tqe) {
@@ -476,6 +481,10 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
 		return 0;
 	}
 
+	if (!wilc->initialized) {
+		tx_complete_fn(priv, 0);
+		return 0;
+	}
 	tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC);
 
 	if (!tqe) {
-- 
2.25.1

  parent reply	other threads:[~2021-09-16 16:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 16:49 [PATCH v2 00/11] wilc1000: add chip wakeup support and few fixes Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 01/11] wilc1000: move 'deinit_lock' lock init/destroy inside module probe Ajay.Kathat
2021-09-21 15:08   ` Kalle Valo
2021-09-16 16:49 ` [PATCH v2 03/11] wilc1000: add new WID to pass wake_enable information to firmware Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 02/11] wilc1000: fix possible memory leak in cfg_scan_result() Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 04/11] wilc1000: configure registers to handle chip wakeup sequence Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 05/11] wilc1000: add reset/terminate/repeat command support for SPI bus Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 06/11] wilc1000: handle read failure issue for clockless registers Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 07/11] wilc1000: ignore clockless registers status response for SPI Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 08/11] wilc1000: invoke chip reset register before firmware download Ajay.Kathat
2021-09-16 16:49 ` Ajay.Kathat [this message]
2021-09-16 16:49 ` [PATCH v2 10/11] wilc1000: use correct write command sequence in wilc_spi_sync_ext() Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 11/11] wilc1000: increase config packets response wait timeout limit Ajay.Kathat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210916164902.74629-10-ajay.kathat@microchip.com \
    --to=ajay.kathat@microchip.com \
    --cc=Claudiu.Beznea@microchip.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.