Commit 260d5d35 authored by Mike Frysinger's avatar Mike Frysinger Committed by Bryan Wu

Blackfin arch: Fix bug - do not overflow the buffer given to us which tends to...

Blackfin arch: Fix bug - do not overflow the buffer given to us which tends to happen when CONFIG_L1_MAX_PIECE is increased past its default
Singed-off-by: default avatarMike Frysinger <vapier.adi@gmail.com>
Signed-off-by: default avatarBryan Wu <cooloney@kernel.org>
parent 1f2d1869
...@@ -549,13 +549,16 @@ EXPORT_SYMBOL(sram_alloc_with_lsl); ...@@ -549,13 +549,16 @@ EXPORT_SYMBOL(sram_alloc_with_lsl);
/* Once we get a real allocator, we'll throw all of this away. /* Once we get a real allocator, we'll throw all of this away.
* Until then, we need some sort of visibility into the L1 alloc. * Until then, we need some sort of visibility into the L1 alloc.
*/ */
static void _l1sram_proc_read(char *buf, int *len, const char *desc, /* Need to keep line of output the same. Currently, that is 44 bytes
* (including newline).
*/
static int _l1sram_proc_read(char *buf, int *len, int count, const char *desc,
struct l1_sram_piece *pfree, const int array_size) struct l1_sram_piece *pfree, const int array_size)
{ {
int i; int i;
*len += sprintf(&buf[*len], "--- L1 %-14s Size PID State\n", desc); *len += sprintf(&buf[*len], "--- L1 %-14s Size PID State \n", desc);
for (i = 0; i < array_size; ++i) { for (i = 0; i < array_size && *len < count; ++i) {
const char *alloc_type; const char *alloc_type;
switch (pfree[i].flag) { switch (pfree[i].flag) {
case SRAM_SLT_NULL: alloc_type = "NULL"; break; case SRAM_SLT_NULL: alloc_type = "NULL"; break;
...@@ -563,31 +566,42 @@ static void _l1sram_proc_read(char *buf, int *len, const char *desc, ...@@ -563,31 +566,42 @@ static void _l1sram_proc_read(char *buf, int *len, const char *desc,
case SRAM_SLT_ALLOCATED: alloc_type = "ALLOCATED"; break; case SRAM_SLT_ALLOCATED: alloc_type = "ALLOCATED"; break;
default: alloc_type = "????"; break; default: alloc_type = "????"; break;
} }
*len += sprintf(&buf[*len], "%p-%p %8i %4i %s\n", /* if we've got a lot of space to cover, omit things */
if ((PAGE_SIZE - 1024) < (CONFIG_L1_MAX_PIECE + 1) * 4 * 44 &&
pfree[i].size == 0)
continue;
*len += sprintf(&buf[*len], "%p-%p %8i %5i %-10s\n",
pfree[i].paddr, pfree[i].paddr + pfree[i].size, pfree[i].paddr, pfree[i].paddr + pfree[i].size,
pfree[i].size, pfree[i].pid, alloc_type); pfree[i].size, pfree[i].pid, alloc_type);
} }
return (i != array_size);
} }
static int l1sram_proc_read(char *buf, char **start, off_t offset, int count, static int l1sram_proc_read(char *buf, char **start, off_t offset, int count,
int *eof, void *data) int *eof, void *data)
{ {
int len = 0; int len = 0;
_l1sram_proc_read(buf, &len, "Scratchpad", if (_l1sram_proc_read(buf, &len, count, "Scratchpad",
l1_ssram, ARRAY_SIZE(l1_ssram)); l1_ssram, ARRAY_SIZE(l1_ssram)))
goto not_done;
#if L1_DATA_A_LENGTH != 0 #if L1_DATA_A_LENGTH != 0
_l1sram_proc_read(buf, &len, "Data A", if (_l1sram_proc_read(buf, &len, count, "Data A",
l1_data_A_sram, ARRAY_SIZE(l1_data_A_sram)); l1_data_A_sram, ARRAY_SIZE(l1_data_A_sram)))
goto not_done;
#endif #endif
#if L1_DATA_B_LENGTH != 0 #if L1_DATA_B_LENGTH != 0
_l1sram_proc_read(buf, &len, "Data B", if (_l1sram_proc_read(buf, &len, count, "Data B",
l1_data_B_sram, ARRAY_SIZE(l1_data_B_sram)); l1_data_B_sram, ARRAY_SIZE(l1_data_B_sram)))
goto not_done;
#endif #endif
#if L1_CODE_LENGTH != 0 #if L1_CODE_LENGTH != 0
_l1sram_proc_read(buf, &len, "Instruction", if (_l1sram_proc_read(buf, &len, count, "Instruction",
l1_inst_sram, ARRAY_SIZE(l1_inst_sram)); l1_inst_sram, ARRAY_SIZE(l1_inst_sram)))
goto not_done;
#endif #endif
*eof = 1;
not_done:
return len; return len;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment