[PATCH dpdk] log: fix double free on cleanup

Robin Jarry rjarry at redhat.com
Sun Dec 1 14:48:13 CET 2024


Stephen Hemminger, Nov 29, 2024 at 17:54:
> On Fri, 29 Nov 2024 17:10:14 +0100
> Robin Jarry <rjarry at redhat.com> wrote:
>
>> @@ -550,11 +555,8 @@ eal_log_init(const char *id)
>>  void
>>  rte_eal_log_cleanup(void)
>>  {
>> -	FILE *log_stream = rte_logs.file;
>> -
>> -	/* don't close stderr on the application */
>> -	if (log_stream != NULL)
>> -		fclose(log_stream);
>> -
>> +	if (rte_logs.is_internal_file && rte_logs.file != NULL)
>> +		fclose(rte_logs.file);
>>  	rte_logs.file = NULL;
>> +	rte_logs.is_internal_file = false;
>>  }
>
> The internal flag is ok, but we still don't want to close
> stderr in cleanup. Only places where syslog or journal wrapper is used.

There is no chance closing stderr will happen with my patch. stderr is 
only returned by rte_log_get_stream() when rte_logs.file is NULL, but 
rte_logs.file is not modified. It is only modified in eal_log_init() 
when --syslog or when running with journald. In both these cases, a new 
file is opened, not stderr.



More information about the dev mailing list