diff mbox

[API-NEXT] linux-gen: init: avoiding segfault if cleaning files

Message ID 1483350102-22261-1-git-send-email-christophe.milard@linaro.org
State Accepted
Commit f53fda91d2919eee33b5a177ef818be1092c890b
Headers show

Commit Message

Christophe Milard Jan. 2, 2017, 9:41 a.m. UTC
The call the the cleanup_files() function (which cleans up possible
remaining file(s) from a defunc OPD with same pid) may use ODP_DBG and
ODP_ERR functions, but is (before this patch) placed before these ODP_*
functions are initialized.
This would surely sigfault.
The call the the cleanup_files() function is hence placed after ODP_DBG and
ODP_ERR function initialization to avoid this situation.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

---
 platform/linux-generic/odp_init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.7.4

Comments

Bill Fischofer Jan. 8, 2017, 3:49 p.m. UTC | #1
On Mon, Jan 2, 2017 at 3:41 AM, Christophe Milard
<christophe.milard@linaro.org> wrote:
> The call the the cleanup_files() function (which cleans up possible

> remaining file(s) from a defunc OPD with same pid) may use ODP_DBG and

> ODP_ERR functions, but is (before this patch) placed before these ODP_*

> functions are initialized.

> This would surely sigfault.

> The call the the cleanup_files() function is hence placed after ODP_DBG and

> ODP_ERR function initialization to avoid this situation.

>

> Signed-off-by: Christophe Milard <christophe.milard@linaro.org>


Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>


> ---

>  platform/linux-generic/odp_init.c | 3 ++-

>  1 file changed, 2 insertions(+), 1 deletion(-)

>

> diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c

> index 1b0d8f8..06c6143 100644

> --- a/platform/linux-generic/odp_init.c

> +++ b/platform/linux-generic/odp_init.c

> @@ -73,7 +73,6 @@ int odp_init_global(odp_instance_t *instance,

>

>         memset(&odp_global_data, 0, sizeof(struct odp_global_data_s));

>         odp_global_data.main_pid = getpid();

> -       cleanup_files(_ODP_TMPDIR, odp_global_data.main_pid);

>

>         enum init_stage stage = NO_INIT;

>         odp_global_data.log_fn = odp_override_log;

> @@ -86,6 +85,8 @@ int odp_init_global(odp_instance_t *instance,

>                         odp_global_data.abort_fn = params->abort_fn;

>         }

>

> +       cleanup_files(_ODP_TMPDIR, odp_global_data.main_pid);

> +

>         if (odp_cpumask_init_global(params)) {

>                 ODP_ERR("ODP cpumask init failed.\n");

>                 goto init_failed;

> --

> 2.7.4

>
Maxim Uvarov Jan. 13, 2017, 1 p.m. UTC | #2
Merged,
Maxim.

On 01/08/17 18:49, Bill Fischofer wrote:
> On Mon, Jan 2, 2017 at 3:41 AM, Christophe Milard

> <christophe.milard@linaro.org> wrote:

>> The call the the cleanup_files() function (which cleans up possible

>> remaining file(s) from a defunc OPD with same pid) may use ODP_DBG and

>> ODP_ERR functions, but is (before this patch) placed before these ODP_*

>> functions are initialized.

>> This would surely sigfault.

>> The call the the cleanup_files() function is hence placed after ODP_DBG and

>> ODP_ERR function initialization to avoid this situation.

>>

>> Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

> 

> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>

> 

>> ---

>>  platform/linux-generic/odp_init.c | 3 ++-

>>  1 file changed, 2 insertions(+), 1 deletion(-)

>>

>> diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c

>> index 1b0d8f8..06c6143 100644

>> --- a/platform/linux-generic/odp_init.c

>> +++ b/platform/linux-generic/odp_init.c

>> @@ -73,7 +73,6 @@ int odp_init_global(odp_instance_t *instance,

>>

>>         memset(&odp_global_data, 0, sizeof(struct odp_global_data_s));

>>         odp_global_data.main_pid = getpid();

>> -       cleanup_files(_ODP_TMPDIR, odp_global_data.main_pid);

>>

>>         enum init_stage stage = NO_INIT;

>>         odp_global_data.log_fn = odp_override_log;

>> @@ -86,6 +85,8 @@ int odp_init_global(odp_instance_t *instance,

>>                         odp_global_data.abort_fn = params->abort_fn;

>>         }

>>

>> +       cleanup_files(_ODP_TMPDIR, odp_global_data.main_pid);

>> +

>>         if (odp_cpumask_init_global(params)) {

>>                 ODP_ERR("ODP cpumask init failed.\n");

>>                 goto init_failed;

>> --

>> 2.7.4

>>
diff mbox

Patch

diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index 1b0d8f8..06c6143 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -73,7 +73,6 @@  int odp_init_global(odp_instance_t *instance,
 
 	memset(&odp_global_data, 0, sizeof(struct odp_global_data_s));
 	odp_global_data.main_pid = getpid();
-	cleanup_files(_ODP_TMPDIR, odp_global_data.main_pid);
 
 	enum init_stage stage = NO_INIT;
 	odp_global_data.log_fn = odp_override_log;
@@ -86,6 +85,8 @@  int odp_init_global(odp_instance_t *instance,
 			odp_global_data.abort_fn = params->abort_fn;
 	}
 
+	cleanup_files(_ODP_TMPDIR, odp_global_data.main_pid);
+
 	if (odp_cpumask_init_global(params)) {
 		ODP_ERR("ODP cpumask init failed.\n");
 		goto init_failed;