diff mbox

platform/linux-dpdk/odp_linux.c: fix memory leak

Message ID 1408997188-22253-1-git-send-email-anders.roxell@linaro.org
State New
Headers show

Commit Message

Anders Roxell Aug. 25, 2014, 8:06 p.m. UTC
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 platform/linux-dpdk/odp_linux.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Anders Roxell Aug. 28, 2014, 6:54 a.m. UTC | #1
On 2014-08-25 22:06, Anders Roxell wrote:
> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
> ---
>  platform/linux-dpdk/odp_linux.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/platform/linux-dpdk/odp_linux.c b/platform/linux-dpdk/odp_linux.c
> index 067bd99..a694f65 100644
> --- a/platform/linux-dpdk/odp_linux.c
> +++ b/platform/linux-dpdk/odp_linux.c
> @@ -78,6 +78,7 @@ void odp_linux_pthread_create(odp_linux_pthread_t *thread_tbl, int num,
>  				odp_run_start_routine(start_args);
>  			lcore_config[cpu].state = FINISHED;
>  		}
> +		free(start_args);
>  	}
>  }
>  
> -- 
> 1.9.1
> 

Ping.
Venkatesh Vivekanandan Aug. 28, 2014, 9:06 a.m. UTC | #2
On 28 August 2014 12:24, Anders Roxell <anders.roxell@linaro.org> wrote:

> On 2014-08-25 22:06, Anders Roxell wrote:
> > Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
> > ---
> >  platform/linux-dpdk/odp_linux.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/platform/linux-dpdk/odp_linux.c
> b/platform/linux-dpdk/odp_linux.c
> > index 067bd99..a694f65 100644
> > --- a/platform/linux-dpdk/odp_linux.c
> > +++ b/platform/linux-dpdk/odp_linux.c
> > @@ -78,6 +78,7 @@ void odp_linux_pthread_create(odp_linux_pthread_t
> *thread_tbl, int num,
> >                               odp_run_start_routine(start_args);
> >                       lcore_config[cpu].state = FINISHED;
> >               }
> > +             free(start_args);
>
No, this should not be done. start_args gets dereferenced in the function
given to pthread. Freeing it here will cause a crash. For eg.,
thr_args->dstpktio is done in pktio_ifburst_thread function of odp_l2fwd.c.

> >       }
> >  }
> >
> > --
> > 1.9.1
> >
>
> Ping.
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Aug. 28, 2014, 9:21 a.m. UTC | #3
On 08/28/2014 10:54 AM, Anders Roxell wrote:
> On 2014-08-25 22:06, Anders Roxell wrote:
>> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
>> ---
>>   platform/linux-dpdk/odp_linux.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/platform/linux-dpdk/odp_linux.c b/platform/linux-dpdk/odp_linux.c
>> index 067bd99..a694f65 100644
>> --- a/platform/linux-dpdk/odp_linux.c
>> +++ b/platform/linux-dpdk/odp_linux.c
>> @@ -78,6 +78,7 @@ void odp_linux_pthread_create(odp_linux_pthread_t *thread_tbl, int num,
>>   				odp_run_start_routine(start_args);
>>   			lcore_config[cpu].state = FINISHED;
>>   		}
>> +		free(start_args);
>>   	}
>>   }
>>   
>> -- 
>> 1.9.1
>>
> Ping.

it's dangerous to do so. free should be in odp_run_start_routine(void 
*arg) or even in dpdk version of odp_linux_pthread_join().
You can free before odp_run_start_routine() parses arguments.

Thanks,
Maxim.


>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/platform/linux-dpdk/odp_linux.c b/platform/linux-dpdk/odp_linux.c
index 067bd99..a694f65 100644
--- a/platform/linux-dpdk/odp_linux.c
+++ b/platform/linux-dpdk/odp_linux.c
@@ -78,6 +78,7 @@  void odp_linux_pthread_create(odp_linux_pthread_t *thread_tbl, int num,
 				odp_run_start_routine(start_args);
 			lcore_config[cpu].state = FINISHED;
 		}
+		free(start_args);
 	}
 }