From d1d4c9c5ffffe070ae4b2019cc924772f39a81cd Mon Sep 17 00:00:00 2001 From: Atish Kumar Patra Date: Mon, 8 Jun 2015 11:08:22 -0600 Subject: [PATCH] lib: qmi_encdec: Ignore unknown optional TLV Currently, Kernel QMI encode/decode library returns an error upon receiving an unknown optional TLV. Any optional TLV in a received QMI message can be ignored and the rest of the message can be decoded. Add support to ignore the unknown optional TLV and decode rest of the message. Change-Id: I8bb509879422c9193c00ed4ef847b0da1d642e33 Signed-off-by: Atish Kumar Patra --- lib/qmi_encdec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/qmi_encdec.c b/lib/qmi_encdec.c index a205a5b719bb..5b0f07612324 100644 --- a/lib/qmi_encdec.c +++ b/lib/qmi_encdec.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -25,6 +25,7 @@ #define TLV_LEN_SIZE sizeof(uint16_t) #define TLV_TYPE_SIZE sizeof(uint8_t) #define U8_MAX 255 +#define OPTIONAL_TLV_TYPE_START 0x10 #ifdef CONFIG_QMI_ENCDEC_DEBUG @@ -793,9 +794,13 @@ static int _qmi_kernel_decode(struct elem_info *ei_array, buf_src += (TLV_TYPE_SIZE + TLV_LEN_SIZE); decoded_bytes += (TLV_TYPE_SIZE + TLV_LEN_SIZE); temp_ei = find_ei(ei_array, tlv_type); - if (!temp_ei) { + if (!temp_ei && (tlv_type < OPTIONAL_TLV_TYPE_START)) { pr_err("%s: Inval element info\n", __func__); return -EINVAL; + } else if (!temp_ei) { + UPDATE_DECODE_VARIABLES(buf_src, + decoded_bytes, tlv_len); + continue; } } else { /*