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

Commit 9aab5245 authored by Karthikeyan Ramasubramanian's avatar Karthikeyan Ramasubramanian
Browse files

msm: qmi: Fix decoding of multi-level nested structures



As per QMI message wire format, type and length information is added
only for elements in the main/outer structure. For elements within a
nested structure, there is no type and length information.

The kernel encode/decode library skips decoding multi-level
nested structures because of the missing length information.
Calculate the maximum message length of such structures through
their element information and complete the decode operation.

Change-Id: I92ed84d7da888ea6360950c288b7b6df7a79f53b
Signed-off-by: default avatarKarthikeyan Ramasubramanian <kramasub@codeaurora.org>
parent 5c3bdb89
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -565,6 +565,11 @@ static int qmi_decode_struct_elem(struct elem_info *ei_array, void *buf_dst,
	int i, rc, decoded_bytes = 0;
	struct elem_info *temp_ei = ei_array;

	if (dec_level > 2 && !tlv_len) {
		tlv_len = qmi_calc_max_msg_len(temp_ei->ei_array, dec_level);
		tlv_len = tlv_len * elem_len;
	}

	for (i = 0; i < elem_len; i++) {
		rc = _qmi_kernel_decode(temp_ei->ei_array, buf_dst, buf_src,
					(tlv_len/elem_len), dec_level);
@@ -636,6 +641,9 @@ static int _qmi_kernel_decode(struct elem_info *ei_array,

	QMI_DECODE_LOG_MSG(in_buf, in_buf_len);
	while (decoded_bytes < in_buf_len) {
		if (dec_level > 2 && temp_ei->data_type == QMI_EOTI)
			return decoded_bytes;

		if (dec_level == 1) {
			tlv_pointer = buf_src;
			QMI_ENCDEC_DECODE_TLV(&tlv_type,