lkml.org 
[lkml]   [2023]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH iwl-next] i40e: Use correct buffer size
From
Thanks you again for your reply.
I learned. I know how to use it, thanks, I'll look at the existing code
and add logs to see how it works.

Thanks again.


On 2023/11/21 19:15, Alexander Lobakin wrote:
> From: Kunwu Chan <chentao@kylinos.cn>
> Date: Tue, 21 Nov 2023 10:12:17 +0800
>
>> Thanks for your reply. I understand what you mean, i.e. the caller of
>> 'kasprintf' is responsible for calling 'kfree' to free up memory.
>>
>> My concern is that in many scenarios, the requested memory will be
>> released after a period of use.
>>
>> Has anyone else forgotten to free up the requested memory when using
>> 'kasprintf'? e.g. 'dam_heap_init' calls 'dma_heap_devnode' to allocate
>> memory:
>> dam_heap_init
>>     -> dma_heap_devnode
>>           -> kasprintf
>>             ->kvasprintf
>>                  ->kmalloc_node_track_caller
>>                   -> __kmalloc_node_track_caller
>>                       -> __do_kmalloc_node
>>                           -> kasan_kmalloc
>>
>>
>> There is no function like 'dam_heap_exit' to free the memmory allocated
>> by dma_heap_devnode.
>>
>> Another case is 'cpuid_devnode'. Will this cause a memory leak, and is
>> there a better way to avoid the memory leak in this case?
>>
>> Or is there a uniform place in the memory management module to free up
>> this memory?
>
> If the lifetime of the allocated buffer equals to the lifetime of the
> kernel, i.e. it's allocated once at kernel init and then used throughout
> the whole uptime, there's no need to free this piece.
> Temporary buffers or buffers allocated from a driver are a different
> story, their lifetime is shorter, which means you always need to
> manually free each of them on exit.
>
>>
>> Thanks,
>> Kunwu
> Thanks,
> Olek

\
 
 \ /
  Last update: 2023-11-22 07:58    [W:0.082 / U:1.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site