[PATCH 20/23][SRU][OEM-5.6] platform/x86: intel_pmc_core: fix bound check in pmc_core_mphy_pg_show()

AceLan Kao acelan.kao at canonical.com
Fri Oct 30 06:02:11 UTC 2020


From: Gaurav Singh <gaurav1086 at gmail.com>

BugLink: https://bugs.launchpad.net/bugs/1899883

Check bounds before accessing map[] array.

Signed-off-by: Gaurav Singh <gaurav1086 at gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
(cherry picked from commit aff374dfe7330be10a20c97bd0b3196c153e9f9e)
Signed-off-by: AceLan Kao <acelan.kao at canonical.com>
---
 drivers/platform/x86/intel_pmc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index 5a0a25e9ccc9..338ea5222555 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -795,7 +795,7 @@ static int pmc_core_mphy_pg_show(struct seq_file *s, void *unused)
 	msleep(10);
 	val_high = pmc_core_reg_read(pmcdev, SPT_PMC_MFPMC_OFFSET);
 
-	for (index = 0; map[index].name && index < 8; index++) {
+	for (index = 0; index < 8 && map[index].name; index++) {
 		seq_printf(s, "%-32s\tState: %s\n",
 			   map[index].name,
 			   map[index].bit_mask & val_low ? "Not power gated" :
-- 
2.25.1




More information about the kernel-team mailing list