Browse Source

qcacmn: Memory Leak in Rx Frag Path

qdf_nbuf_cat API used to call skb_free
on src address but was later modified
so that the caller of qdf_nbuf_cat is
responsible for freeing the src memory

Due to this change in  the API, the
freeing of src memory on caller side
was not taken care and will lead to
mem leak

Hence add qdf_nbuf_free after calling
qdf_nbuf_cat if it returns success.

If qdf_nbuf_cat returns failure, then
freeing is taken care as part of error
handling in parent function.

CRs-Fixed: 2411320
Change-Id: If50eb9279d0cf26a0cf57444cb69e56f11995720
phadiman 6 years ago
parent
commit
2c146ea33a
1 changed files with 10 additions and 3 deletions
  1. 10 3
      dp/wifi3.0/dp_rx.h

+ 10 - 3
dp/wifi3.0/dp_rx.h

@@ -803,10 +803,17 @@ static inline QDF_STATUS dp_rx_defrag_concat(qdf_nbuf_t dst, qdf_nbuf_t src)
 	 * (This is needed, because the headroom of the dst buffer
 	 * contains the rx desc.)
 	 */
-	if (qdf_nbuf_cat(dst, src))
-		return QDF_STATUS_E_DEFRAG_ERROR;
+	if (!qdf_nbuf_cat(dst, src)) {
+		/*
+		 * qdf_nbuf_cat does not free the src memory.
+		 * Free src nbuf before returning
+		 * For failure case the caller takes of freeing the nbuf
+		 */
+		qdf_nbuf_free(src);
+		return QDF_STATUS_SUCCESS;
+	}
 
-	return QDF_STATUS_SUCCESS;
+	return QDF_STATUS_E_DEFRAG_ERROR;
 }
 
 /*