Skip to contentSkip to conversation

fix bound check in pmc_core_mphy_pg_show

PATCH In review Gaurav Singh 2 participants 2 messages Jun 24, 2020 – Jul 10, 2020 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix bound check in pmc_core_mphy_pg_show

Check bounds before accessing map[].

---
 drivers/platform/x86/intel_pmc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_pmc_core.c +1 -1
index 7c8bdab078cf..f571f9cf7217 100644
@@ -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" :
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Gaurav Singh

Check bounds before accessing map[].

Pushed to my review and testing queue, thanks!

Quoted 19 lines
---
 drivers/platform/x86/intel_pmc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_pmc_core.c +1 -2
index 7c8bdab078cf..f571f9cf7217 100644
@@ -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" :
--
Quoted 2 lines

2.17.1

--
With Best Regards,
Andy Shevchenko