From 53241c46d5b0cdd49d8ccc0d984ba0d427cd7597 Mon Sep 17 00:00:00 2001 From: Vidyullatha Kanchanapally Date: Thu, 13 Apr 2017 19:16:24 +0530 Subject: [PATCH] qcacld-3.0: Fix logging signed integer cfg item A signed integer cfg item if less that 32 bits is logged improperly i.e. the sign of the cfg item is being lost. Fix this by preserving the sign. Change-Id: I6eaba2bfa06d763bcdf197de0a4182c12c74d1af CRs-Fixed: 2033298 --- core/hdd/src/wlan_hdd_cfg.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c index 0f42a09348e9..2e135f26a825 100644 --- a/core/hdd/src/wlan_hdd_cfg.c +++ b/core/hdd/src/wlan_hdd_cfg.c @@ -4441,12 +4441,23 @@ static QDF_STATUS hdd_cfg_get_config(struct reg_table_entry *reg_table, (WLAN_PARAM_SignedInteger == pRegEntry->RegType) || (WLAN_PARAM_HexInteger == pRegEntry->RegType)) { value = 0; + + if ((pRegEntry->VarSize > sizeof(value)) || + (pRegEntry->VarSize == 0)) { + pr_warn("Invalid length of %s: %d", + pRegEntry->RegName, pRegEntry->VarSize); + continue; + } + memcpy(&value, pField, pRegEntry->VarSize); if (WLAN_PARAM_HexInteger == pRegEntry->RegType) { fmt = "%x"; } else if (WLAN_PARAM_SignedInteger == pRegEntry->RegType) { fmt = "%d"; + value = sign_extend32( + value, + pRegEntry->VarSize * 8 - 1); } else { fmt = "%u"; }