diff mbox

odp_linux.c: Call ODP_ERR if malloc fails

Message ID 1410914938-33048-1-git-send-email-mike.holmes@linaro.org
State Accepted
Commit 3df2ca6f0685a532353307f01011e7550ba0a3e6
Headers show

Commit Message

Mike Holmes Sept. 17, 2014, 12:48 a.m. UTC
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 platform/linux-generic/odp_linux.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Maxim Uvarov Sept. 22, 2014, 9:41 a.m. UTC | #1
Merged!

Maxim.

On 09/17/2014 04:48 AM, Mike Holmes wrote:
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>   platform/linux-generic/odp_linux.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/platform/linux-generic/odp_linux.c b/platform/linux-generic/odp_linux.c
> index e21e467..9251ec9 100644
> --- a/platform/linux-generic/odp_linux.c
> +++ b/platform/linux-generic/odp_linux.c
> @@ -46,7 +46,8 @@ static void *odp_run_start_routine(void *arg)
>   
>   
>   void odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl, int num,
> -		int first_core, void *(*start_routine) (void *), void *arg)
> +			       int first_core,
> +			       void *(*start_routine) (void *), void *arg)
>   {
>   	int i;
>   	cpu_set_t cpu_set;
> @@ -73,6 +74,9 @@ void odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl, int num,
>   					    sizeof(cpu_set_t), &cpu_set);
>   
>   		start_args = malloc(sizeof(odp_start_args_t));
> +		if (start_args == NULL)
> +			ODP_ERR("Malloc failed");
> +
>   		memset(start_args, 0, sizeof(odp_start_args_t));
>   		start_args->start_routine = start_routine;
>   		start_args->arg           = arg;
diff mbox

Patch

diff --git a/platform/linux-generic/odp_linux.c b/platform/linux-generic/odp_linux.c
index e21e467..9251ec9 100644
--- a/platform/linux-generic/odp_linux.c
+++ b/platform/linux-generic/odp_linux.c
@@ -46,7 +46,8 @@  static void *odp_run_start_routine(void *arg)
 
 
 void odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl, int num,
-		int first_core, void *(*start_routine) (void *), void *arg)
+			       int first_core,
+			       void *(*start_routine) (void *), void *arg)
 {
 	int i;
 	cpu_set_t cpu_set;
@@ -73,6 +74,9 @@  void odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl, int num,
 					    sizeof(cpu_set_t), &cpu_set);
 
 		start_args = malloc(sizeof(odp_start_args_t));
+		if (start_args == NULL)
+			ODP_ERR("Malloc failed");
+
 		memset(start_args, 0, sizeof(odp_start_args_t));
 		start_args->start_routine = start_routine;
 		start_args->arg           = arg;