Skip to content

Commit 59ab9d7

Browse files
author
Fox Snowpatch
committed
1 parent 5c2c0ba commit 59ab9d7

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

arch/powerpc/platforms/pseries/pseries_energy.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ static int drc_index_to_cpu(u32 drc_index)
184184
#define FLAGS_MODE1 0x004E200000080E01UL
185185
#define FLAGS_MODE2 0x004E200000080401UL
186186
#define FLAGS_ACTIVATE 0x100
187+
#define BEST_ENERGY_LIST_MAX_ENTRIES (PAGE_SIZE / (sizeof(u32) * 2))
187188

188189
static ssize_t get_best_energy_list(char *page, int activate)
189190
{
@@ -208,6 +209,11 @@ static ssize_t get_best_energy_list(char *page, int activate)
208209
return -EINVAL;
209210
}
210211

212+
if (retbuf[0] > BEST_ENERGY_LIST_MAX_ENTRIES) {
213+
free_page((unsigned long)buf_page);
214+
return -EINVAL;
215+
}
216+
211217
cnt = retbuf[0];
212218
for (i = 0; i < cnt; i++) {
213219
cpu = drc_index_to_cpu(buf_page[2*i+1]);

0 commit comments

Comments
 (0)