File powerpc-utils.bug-945968_allocate-workarea-memory-instead-of-using-stac.patch of Package powerpc-utils

From 96a83ab8b84576517a28bc8f4d8e684e6c86befd Mon Sep 17 00:00:00 2001
From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Date: Wed, 2 Sep 2015 10:36:25 -0400
Subject: [PATCH] drmgr: Allocate workarea memory instead of using stack

The configure_connector() routine declares a 4K buffer on the stack, this
is causing odd behaviors in drmgr such as segfaults in libc malloc code.
The workarea should be malloc()'ed instead of being on the stack.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 src/drmgr/rtas_calls.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/drmgr/rtas_calls.c b/src/drmgr/rtas_calls.c
index b7b5b82..e312260 100644
--- a/src/drmgr/rtas_calls.c
+++ b/src/drmgr/rtas_calls.c
@@ -263,7 +263,7 @@ set_indicator_error(int error)
 struct of_node *
 configure_connector(int index)
 {
-	char workarea[WORK_SIZE];
+	char *workarea;
 	struct of_node *node;
 	struct of_node *first_node = NULL;
 	struct of_node *last_node = NULL;	/* Last node processed */
@@ -274,8 +274,12 @@ configure_connector(int index)
 
 	say(DEBUG, "Configuring connector for drc index %x\n", index);
 
+	workarea = zalloc(WORK_SIZE);
+	if (!workarea)
+		return NULL;
+
 	/* initialize work area and args structure */
-	work_int = (int *) &workarea[0];
+	work_int = (int *)workarea;
 	work_int[0] = htobe32(index);
 	work_int[1] = 0;
 
@@ -397,6 +401,7 @@ configure_connector(int index)
 		}
 	}
 
+	free(workarea);
 	return first_node;
 }
 
-- 
1.8.5.6

openSUSE Build Service is sponsored by