From: Markus Armbruster nmi_create_files() in arch/i386/oprofile/nmi_int.c depends on model->num_counters (number of performance counters) being less than 10. While this is currently the case, it's too clever by half. Other archs aren't quite as clever: they assume 100. I suggest to normalize them all to 1000. Cc: Philippe Elie Cc: John Levon Signed-off-by: Andrew Morton --- arch/alpha/oprofile/common.c | 2 +- arch/i386/oprofile/nmi_int.c | 4 ++-- arch/mips/oprofile/common.c | 2 +- arch/powerpc/oprofile/common.c | 2 +- arch/sh/oprofile/op_model_sh7750.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff -puN arch/alpha/oprofile/common.c~oprofile-fix-unnecessary-cleverness arch/alpha/oprofile/common.c --- 25/arch/alpha/oprofile/common.c~oprofile-fix-unnecessary-cleverness Mon May 15 15:05:00 2006 +++ 25-akpm/arch/alpha/oprofile/common.c Mon May 15 15:05:00 2006 @@ -112,7 +112,7 @@ op_axp_create_files(struct super_block * for (i = 0; i < model->num_counters; ++i) { struct dentry *dir; - char buf[3]; + char buf[4]; snprintf(buf, sizeof buf, "%d", i); dir = oprofilefs_mkdir(sb, root, buf); diff -puN arch/i386/oprofile/nmi_int.c~oprofile-fix-unnecessary-cleverness arch/i386/oprofile/nmi_int.c --- 25/arch/i386/oprofile/nmi_int.c~oprofile-fix-unnecessary-cleverness Mon May 15 15:05:00 2006 +++ 25-akpm/arch/i386/oprofile/nmi_int.c Mon May 15 15:05:27 2006 @@ -303,7 +303,7 @@ static int nmi_create_files(struct super for (i = 0; i < model->num_counters; ++i) { struct dentry * dir; - char buf[2]; + char buf[4]; /* quick little hack to _not_ expose a counter if it is not * available for use. This should protect userspace app. @@ -313,7 +313,7 @@ static int nmi_create_files(struct super if (unlikely(!avail_to_resrv_perfctr_nmi_bit(i))) continue; - snprintf(buf, 2, "%d", i); + snprintf(buf, sizeof(buf), "%d", i); dir = oprofilefs_mkdir(sb, root, buf); oprofilefs_create_ulong(sb, dir, "enabled", &counter_config[i].enabled); oprofilefs_create_ulong(sb, dir, "event", &counter_config[i].event); diff -puN arch/mips/oprofile/common.c~oprofile-fix-unnecessary-cleverness arch/mips/oprofile/common.c --- 25/arch/mips/oprofile/common.c~oprofile-fix-unnecessary-cleverness Mon May 15 15:05:00 2006 +++ 25-akpm/arch/mips/oprofile/common.c Mon May 15 15:05:00 2006 @@ -38,7 +38,7 @@ static int op_mips_create_files(struct s for (i = 0; i < model->num_counters; ++i) { struct dentry *dir; - char buf[3]; + char buf[4]; snprintf(buf, sizeof buf, "%d", i); dir = oprofilefs_mkdir(sb, root, buf); diff -puN arch/powerpc/oprofile/common.c~oprofile-fix-unnecessary-cleverness arch/powerpc/oprofile/common.c --- 25/arch/powerpc/oprofile/common.c~oprofile-fix-unnecessary-cleverness Mon May 15 15:05:00 2006 +++ 25-akpm/arch/powerpc/oprofile/common.c Mon May 15 15:05:00 2006 @@ -93,7 +93,7 @@ static int op_powerpc_create_files(struc for (i = 0; i < model->num_counters; ++i) { struct dentry *dir; - char buf[3]; + char buf[4]; snprintf(buf, sizeof buf, "%d", i); dir = oprofilefs_mkdir(sb, root, buf); diff -puN arch/sh/oprofile/op_model_sh7750.c~oprofile-fix-unnecessary-cleverness arch/sh/oprofile/op_model_sh7750.c --- 25/arch/sh/oprofile/op_model_sh7750.c~oprofile-fix-unnecessary-cleverness Mon May 15 15:05:00 2006 +++ 25-akpm/arch/sh/oprofile/op_model_sh7750.c Mon May 15 15:05:00 2006 @@ -198,7 +198,7 @@ static int sh7750_perf_counter_create_fi for (i = 0; i < NR_CNTRS; i++) { struct dentry *dir; - char buf[3]; + char buf[4]; snprintf(buf, sizeof(buf), "%d", i); dir = oprofilefs_mkdir(sb, root, buf); _