diff mbox

[PMQA] cpuidle_killer: allocate per cpu process array dynamically

Message ID 1398834510-8433-1-git-send-email-sanjay.rawat@linaro.org
State New
Headers show

Commit Message

Sanjay Singh Rawat April 30, 2014, 5:08 a.m. UTC
currently percpu process array is set to 2, which results in segfault

Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
---
 cpuidle/cpuidle_killer.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/cpuidle/cpuidle_killer.c b/cpuidle/cpuidle_killer.c
index 5e7320f..09009ef 100644
--- a/cpuidle/cpuidle_killer.c
+++ b/cpuidle/cpuidle_killer.c
@@ -104,7 +104,7 @@  int main(int argc, char *argv[])
 {
 	int ret, i, nrcpus = 2;
 	int nrsleeps, delay;
-	pid_t pids[nrcpus];
+	pid_t *pids;
 	struct timex timex = { 0 };
 
 	if (adjtimex(&timex) < 0) {
@@ -121,6 +121,11 @@  int main(int argc, char *argv[])
 	}
 
 	fprintf(stderr, "found %d cpu(s)\n", nrcpus);
+	pids = (pid_t *) calloc(nrcpus, sizeof(pid_t));
+	if (pids == NULL) {
+		fprintf(stderr, "error: calloc failed\n");
+		return 1;
+	}
 
 	for (i = 0; i < nrcpus; i++) {