瀏覽代碼

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
Vidyullatha Kanchanapally 8 年之前
父節點
當前提交
53241c46d5
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      core/hdd/src/wlan_hdd_cfg.c

+ 11 - 0
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";
 			}