[PATCH] platform/x86: intel_pmc_core: Prevent possibile overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Low Power Mode (LPM) priority is encoded in 4 bits. Yet, this value is used
as an index to an array whose element size was less than 16, leading to the
possibility of overflow should we read a larger than expected priority. Set
the array size to 16 to prevent this.

Reported-by: Evgeny Novikov <novikov@xxxxxxxxx>
Signed-off-by: David E. Box <david.e.box@xxxxxxxxxxxxxxx>
---
 drivers/platform/x86/intel_pmc_core.c | 2 +-
 drivers/platform/x86/intel_pmc_core.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index b0e486a6bdfb..2a761fe98277 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -1451,7 +1451,7 @@ DEFINE_SHOW_ATTRIBUTE(pmc_core_pkgc);
 
 static void pmc_core_get_low_power_modes(struct pmc_dev *pmcdev)
 {
-	u8 lpm_priority[LPM_MAX_NUM_MODES];
+	u8 lpm_priority[LPM_MAX_PRI];
 	u32 lpm_en;
 	int mode, i, p;
 
diff --git a/drivers/platform/x86/intel_pmc_core.h b/drivers/platform/x86/intel_pmc_core.h
index e8dae9c6c45f..b98c2b44c938 100644
--- a/drivers/platform/x86/intel_pmc_core.h
+++ b/drivers/platform/x86/intel_pmc_core.h
@@ -190,6 +190,7 @@ enum ppfear_regs {
 #define LPM_MAX_NUM_MODES			8
 #define GET_X2_COUNTER(v)			((v) >> 1)
 #define LPM_STS_LATCH_MODE			BIT(31)
+#define LPM_MAX_PRI				16	/* size of 4 bits */
 
 #define TGL_PMC_SLP_S0_RES_COUNTER_STEP		0x7A
 #define TGL_PMC_LTR_THC0			0x1C04
-- 
2.25.1




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux