Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 746bec06 authored by gaurank kathpalia's avatar gaurank kathpalia Committed by nshrivas
Browse files

qcacld-3.0: Avoid memory leak when adding a TX pattern

In wma_process_add_periodic_tx_ptrn_ind() the buffer allocated for the
WMI parameter will be leaked if wma_find_vdev_by_addr() fails. To
avoid this, reorder the operations so that the buffer is not allocated
unless wma_find_vdev_by_addr() is successful.

Change-Id: Idbd180dcc1bcae5b71f6a56adcfa3b4a7e2595da
CRs-Fixed: 2371905
parent 22743472
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -3697,15 +3697,6 @@ QDF_STATUS wma_process_add_periodic_tx_ptrn_ind(WMA_HANDLE handle,
		return QDF_STATUS_E_INVAL;
	}

	params_ptr = qdf_mem_malloc(sizeof(*params_ptr));

	if (!params_ptr) {
		WMA_LOGE(
			"%s: unable to allocate memory for periodic_tx_pattern",
			 __func__);
		return QDF_STATUS_E_NOMEM;
	}

	if (!wma_find_vdev_by_addr(wma_handle,
				   pAddPeriodicTxPtrnParams->mac_address.bytes,
				   &vdev_id)) {
@@ -3714,6 +3705,13 @@ QDF_STATUS wma_process_add_periodic_tx_ptrn_ind(WMA_HANDLE handle,
		return QDF_STATUS_E_INVAL;
	}

	params_ptr = qdf_mem_malloc(sizeof(*params_ptr));
	if (!params_ptr) {
		WMA_LOGE("%s: unable to allocate memory for periodic_tx_pattern",
			__func__);
		return QDF_STATUS_E_NOMEM;
	}

	params_ptr->ucPtrnId = pAddPeriodicTxPtrnParams->ucPtrnId;
	params_ptr->ucPtrnSize = pAddPeriodicTxPtrnParams->ucPtrnSize;
	params_ptr->usPtrnIntervalMs =