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>, <Sripad.Balwadgi@microchip.com>,
	<Ajay.Kathat@microchip.com>
Subject: [PATCH 5/5] wilc1000: add valid vmm_entry check before fetching from TX queue
Date: Wed, 4 May 2022 16:19:27 +0000	[thread overview]
Message-ID: <20220504161924.2146601-5-ajay.kathat@microchip.com> (raw)
In-Reply-To: <20220504161924.2146601-1-ajay.kathat@microchip.com>

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

'vmm_table' array contains the size of data buffer length including host
header length. In 'vmm_table' array, the Zero value means the end of
vmm_entries that needs to transfer to firmware which is calculated based on
VMM free size in firmware.

Use 'vmm_table' valid entry check before fetching the entry from TX queue to
only copy valid number of entries to avoid possible NULL pointer exception
observed sometimes during large file transfers.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
---
 drivers/net/wireless/microchip/wilc1000/wlan.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index fb5633a05fd5..48441f0389ca 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -875,14 +875,15 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
 		char *bssid;
 		u8 mgmt_ptk = 0;
 
+		if (vmm_table[i] == 0 || vmm_entries_ac[i] >= NQUEUES)
+			break;
+
 		tqe = wilc_wlan_txq_remove_from_head(wilc, vmm_entries_ac[i]);
-		ac_pkt_num_to_chip[vmm_entries_ac[i]]++;
 		if (!tqe)
 			break;
 
+		ac_pkt_num_to_chip[vmm_entries_ac[i]]++;
 		vif = tqe->vif;
-		if (vmm_table[i] == 0)
-			break;
 
 		le32_to_cpus(&vmm_table[i]);
 		vmm_sz = FIELD_GET(WILC_VMM_BUFFER_SIZE, vmm_table[i]);
-- 
2.25.1

  parent reply	other threads:[~2022-05-04 16:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04 16:19 [PATCH 1/5] wilc1000: increase firmware version array size Ajay.Kathat
2022-05-04 16:19 ` [PATCH 2/5] wilc1000: use fixed function base register value to access SDIO_FBR_ENABLE_CSA Ajay.Kathat
2022-05-04 16:19 ` [PATCH 4/5] wilc1000: use 'u64' datatype for cookie variable Ajay.Kathat
2022-05-04 16:19 ` [PATCH 3/5] wilc1000: fix crash observed in AP mode with cfg80211_register_netdevice() Ajay.Kathat
2022-05-09 11:50   ` Kalle Valo
2022-05-09 13:49     ` Ajay.Kathat
2022-05-09 19:44       ` Johannes Berg
2022-05-10  9:55         ` Ajay.Kathat
2022-05-11  4:41           ` Kalle Valo
2022-05-04 16:19 ` Ajay.Kathat [this message]
2022-05-11  5:25 ` [PATCH 1/5] wilc1000: increase firmware version array size Kalle Valo

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=20220504161924.2146601-5-ajay.kathat@microchip.com \
    --to=ajay.kathat@microchip.com \
    --cc=Claudiu.Beznea@microchip.com \
    --cc=Sripad.Balwadgi@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.