summaryrefslogtreecommitdiff
path: root/hif
diff options
context:
space:
mode:
authorchenguo <chenguo@codeaurora.org>2017-10-26 11:24:01 +0800
committersnandini <snandini@codeaurora.org>2017-10-31 17:39:02 -0700
commit23b6502d88aed2e97179936a15c4cccbd8c61d84 (patch)
treea835d96c2fb58bfd6a56c38159da072b52007beb /hif
parent9f7b297a38dd23cd0951862d0d277885b3ee7ca8 (diff)
downloadqca-wfi-host-cmn-23b6502d88aed2e97179936a15c4cccbd8c61d84.tar.gz
qcacmn: Fix memory leak for RX path of SDIO WLAN
There is a memory leak for RX path of SDIO WLAN if skb allocation fails. Add condition check and free all resources for scenario. Change-Id: Ic4a58d3d4e93f1d6d57bfb045dfdeb131b24f72a CRs-Fixed: 2128051
Diffstat (limited to 'hif')
-rw-r--r--hif/src/sdio/hif_sdio_recv.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/hif/src/sdio/hif_sdio_recv.c b/hif/src/sdio/hif_sdio_recv.c
index fcd2da87d..548352ad1 100644
--- a/hif/src/sdio/hif_sdio_recv.c
+++ b/hif/src/sdio/hif_sdio_recv.c
@@ -293,10 +293,18 @@ QDF_STATUS hif_dev_alloc_and_prepare_rx_packets(struct hif_sdio_device *pdev,
/* for NO RESOURCE error, no need to flush data queue */
if (QDF_IS_STATUS_ERROR(status)
&& (status != QDF_STATUS_E_RESOURCES)) {
- while (!HTC_QUEUE_EMPTY(queue))
+ while (!HTC_QUEUE_EMPTY(queue)) {
+ qdf_nbuf_t netbuf;
packet = htc_packet_dequeue(queue);
+ if (packet == NULL)
+ break;
+ netbuf = (qdf_nbuf_t) packet->pNetBufContext;
+ if (netbuf)
+ qdf_nbuf_free(netbuf);
+ }
}
-
+ if (status == QDF_STATUS_E_RESOURCES)
+ status = QDF_STATUS_SUCCESS;
return status;
}
@@ -967,8 +975,20 @@ QDF_STATUS hif_dev_recv_message_pending_handler(struct hif_sdio_device *pdev,
hif_dev_recv_packet(pdev, packet,
packet->ActualLength,
mail_box_index);
- if (QDF_IS_STATUS_ERROR(status))
+ if (QDF_IS_STATUS_ERROR(status)) {
+ while (!HTC_QUEUE_EMPTY(&recv_pkt_queue)) {
+ qdf_nbuf_t netbuf;
+ packet =
+ htc_packet_dequeue(&recv_pkt_queue);
+ if (packet == NULL)
+ break;
+ netbuf =
+ (qdf_nbuf_t) packet->pNetBufContext;
+ if (netbuf)
+ qdf_nbuf_free(netbuf);
+ }
break;
+ }
/* sent synchronously, queue this packet for
* synchronous completion
*/