diff mbox series

[2/5] wilc1000: free resource in wilc_wlan_txq_add_net_pkt() for failure path

Message ID 20201125114059.10006-3-ajay.kathat@microchip.com
State New
Headers show
Series wilc1000: added WMM support and minor fixes | expand

Commit Message

Ajay Singh Nov. 25, 2020, 11:41 a.m. UTC
From: Ajay Singh <ajay.kathat@microchip.com>

Before returing from wilc_wlan_txq_add_net_pkt() invoke tx_complete_fn()
callback to free up allocated memory for failure cases.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
---
 drivers/net/wireless/microchip/wilc1000/wlan.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 6a82fb2f283e..f0cc2da7c9c7 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -284,13 +284,17 @@  int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
 
 	wilc = vif->wilc;
 
-	if (wilc->quit)
+	if (wilc->quit) {
+		tx_complete_fn(priv, 0);
 		return 0;
+	}
 
 	tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC);
 
-	if (!tqe)
+	if (!tqe) {
+		tx_complete_fn(priv, 0);
 		return 0;
+	}
 	tqe->type = WILC_NET_PKT;
 	tqe->buffer = buffer;
 	tqe->buffer_size = buffer_size;