qcacmn: Use wmi msg length to allocate WMI buffer for QMI events

For QMI events, recevid QMI event length is used to allocate wmi buffer
using wmi_buf_alloc. The received QMI event length includes WMI head
room and wmi_buf_alloc also try to reserve WMI head room again.
Because of this, WMI buffer allocation is exceeding max WMI msg length.

To resolve this, use length of the received actual WMI msg to allocate
WMI event buffer using wmi_buf_alloc.

Change-Id: Icd259988c4b1091580a35aaf2c3fabc606e0f2a9
CRs-Fixed: 2786326
This commit is contained in:
Bapiraju Alla
2020-10-16 11:36:46 +05:30
committed by snandini
parent 807a1944f2
commit bc159feb4e

View File

@@ -2536,14 +2536,26 @@ static int __wmi_process_qmi_fw_event(void *wmi_cb_ctx, void *buf, int len)
struct wmi_unified *wmi_handle = wmi_cb_ctx;
wmi_buf_t evt_buf;
uint32_t evt_id;
int wmi_msg_len;
if (!wmi_handle || !buf)
return -EINVAL;
evt_buf = wmi_buf_alloc(wmi_handle, len);
/**
* Subtract WMI_MIN_HEAD_ROOM from received QMI event length to get
* wmi message length
*/
wmi_msg_len = len - WMI_MIN_HEAD_ROOM;
evt_buf = wmi_buf_alloc(wmi_handle, wmi_msg_len);
if (!evt_buf)
return -ENOMEM;
/*
* Set the length of the buffer to match the allocation size.
*/
qdf_nbuf_set_pktlen(evt_buf, len);
qdf_mem_copy(qdf_nbuf_data(evt_buf), buf, len);
evt_id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
wmi_debug("Received WMI_EVT_ID: %d over qmi", evt_id);