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

Commit d2fb462b authored by Zhenhua Huang's avatar Zhenhua Huang
Browse files

soc: qcom: socinfo: Add check for subtype id



There's an overflow when subtype id is greater than 3 in current
design. Add a check to ensure returning correct value.

Change-Id: Ie8d234792f7370c95782a86e16affd383ed53c18
Signed-off-by: default avatarZhenhua Huang <zhenhuah@codeaurora.org>
parent 4c0cc16e
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -121,7 +121,8 @@ const char *hw_platform_subtype[] = {
	[PLATFORM_SUBTYPE_UNKNOWN] = "Unknown",
	[PLATFORM_SUBTYPE_CHARM] = "charm",
	[PLATFORM_SUBTYPE_STRANGE] = "strange",
	[PLATFORM_SUBTYPE_STRANGE_2A] = "strange_2a,"
	[PLATFORM_SUBTYPE_STRANGE_2A] = "strange_2a",
	[PLATFORM_SUBTYPE_INVALID] = "Invalid",
};

/* Used to parse shared memory.  Must match the modem. */
@@ -774,11 +775,15 @@ msm_get_platform_subtype(struct device *dev,
		}
		return snprintf(buf, PAGE_SIZE, "%-.32s\n",
					qrd_hw_platform_subtype[hw_subtype]);
	} else {
		if (hw_subtype >= PLATFORM_SUBTYPE_INVALID) {
			pr_err("Invalid hardware platform subtype\n");
			hw_subtype = PLATFORM_SUBTYPE_INVALID;
		}

		return snprintf(buf, PAGE_SIZE, "%-.32s\n",
			hw_platform_subtype[hw_subtype]);
	}
}

static ssize_t
msm_get_platform_subtype_id(struct device *dev,