Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Kunwu Chan <chentao@kylinos.cn>
Cc: kunwu.chan@hotmail.com, netdev@vger.kernel.org,
	jesse.brandeburg@intel.com, linux-kernel@vger.kernel.org,
	edumazet@google.com, intel-wired-lan@lists.osuosl.org,
	jeffrey.t.kirsher@intel.com, horms@kernel.org, kuba@kernel.org,
	anthony.l.nguyen@intel.com, pabeni@redhat.com,
	davem@davemloft.net, shannon.nelson@amd.com
Subject: Re: [Intel-wired-lan] [PATCH iwl-next] i40e: Use correct buffer size
Date: Tue, 21 Nov 2023 12:15:30 +0100	[thread overview]
Message-ID: <e5b458fa-c7ad-424d-8416-2947d684b5dc@intel.com> (raw)
In-Reply-To: <55b77a28-a680-4465-bb57-2a5cb20ce06a@kylinos.cn>

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
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

  reply	other threads:[~2023-11-21 11:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-12 11:01 [Intel-wired-lan] [PATCH] i40e: Use correct buffer size Kunwu Chan
2023-11-13  9:31 ` Simon Horman
2023-11-15  3:10   ` Kunwu Chan
2023-11-15  3:14   ` [Intel-wired-lan] [PATCH iwl-next] " Kunwu Chan
2023-11-15  9:21     ` Simon Horman
2023-11-15 15:39     ` Alexander Lobakin
2023-11-19 15:12       ` Kunwu Chan
2023-11-20 11:41         ` Alexander Lobakin
2023-11-21  2:12           ` Kunwu Chan
2023-11-21 11:15             ` Alexander Lobakin [this message]
2023-11-22  6:57               ` Kunwu Chan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e5b458fa-c7ad-424d-8416-2947d684b5dc@intel.com \
    --to=aleksander.lobakin@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=chentao@kylinos.cn \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=kuba@kernel.org \
    --cc=kunwu.chan@hotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shannon.nelson@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox