From d448fad508d437c3a7274a98e626846fda75863c Mon Sep 17 00:00:00 2001 From: Tiger Yu Date: Fri, 3 Nov 2017 17:21:43 +0800 Subject: [PATCH] qcacmn: Fix memory leak for SDIO RX path in the HIF layer qcacld-2.0 to qcacmn propagation There is a memory leak if fail to process the rx packet header in the HIF layer. Add sanity checking to free all resources if failure hit. Change-Id: Ifa443dcec0a31ae39356ac1ddf7cfe652d8968ce CRs-Fixed: 2137736 --- hif/src/sdio/hif_sdio_recv.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hif/src/sdio/hif_sdio_recv.c b/hif/src/sdio/hif_sdio_recv.c index 548352ad177e..ae617c90c0c3 100644 --- a/hif/src/sdio/hif_sdio_recv.c +++ b/hif/src/sdio/hif_sdio_recv.c @@ -1025,8 +1025,11 @@ QDF_STATUS hif_dev_recv_message_pending_handler(struct hif_sdio_device *pdev, hif_dev_process_recv_header(pdev, packet, look_aheads, &num_look_aheads); - if (QDF_IS_STATUS_ERROR(status)) + if (QDF_IS_STATUS_ERROR(status)) { + HTC_PACKET_ENQUEUE_TO_HEAD(&sync_completed_pkts_queue, + packet); break; + } netbuf = (qdf_nbuf_t) packet->pNetBufContext; /* set data length */ @@ -1044,8 +1047,13 @@ QDF_STATUS hif_dev_recv_message_pending_handler(struct hif_sdio_device *pdev, pipeid); } } - if (QDF_IS_STATUS_ERROR(status)) + + if (QDF_IS_STATUS_ERROR(status)) { + if (!HTC_QUEUE_EMPTY(&sync_completed_pkts_queue)) + hif_dev_free_recv_pkt_queue( + &sync_completed_pkts_queue); break; + } if (num_look_aheads == 0) { /* no more look aheads */