public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* question on devm_kfree
@ 2012-08-08  5:56 Venu Byravarasu
  2012-08-08  6:30 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: Venu Byravarasu @ 2012-08-08  5:56 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org

As per comments related to devm_kzalloc, memory allocated using it is freed automatically.
However there is a function called devm_kfree, comment section of which says that it is used to free memory allocated using devm_kzalloc().
If memory allocated by devm_kzalloc is freed automatically, what's the need & significance of devm_kfree?

Thanks,
Venu


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question on devm_kfree
  2012-08-08  5:56 question on devm_kfree Venu Byravarasu
@ 2012-08-08  6:30 ` Lars-Peter Clausen
  2012-08-08  6:38   ` Venu Byravarasu
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2012-08-08  6:30 UTC (permalink / raw)
  To: Venu Byravarasu; +Cc: linux-kernel@vger.kernel.org

On 08/08/2012 07:56 AM, Venu Byravarasu wrote:
> As per comments related to devm_kzalloc, memory allocated using it is
> freed automatically.
> However there is a function called devm_kfree, comment section of which
> says that it is used to free memory allocated using devm_kzalloc().
> If memory allocated by devm_kzalloc is freed automatically, what's the
> need & significance of devm_kfree?
> 
> Thanks,
> Venu
>

Hi,

Memory allocated with devm_kzalloc is freed at the end of the lifetime of the
device it is attached to. If you for some reason want to free allocated with
memory devm_kzalloc before that of the lifetime of the device can use devm_kfree.


- Lars

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: question on devm_kfree
  2012-08-08  6:30 ` Lars-Peter Clausen
@ 2012-08-08  6:38   ` Venu Byravarasu
  0 siblings, 0 replies; 3+ messages in thread
From: Venu Byravarasu @ 2012-08-08  6:38 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-kernel@vger.kernel.org

> -----Original Message-----
> From: Lars-Peter Clausen [mailto:lars@metafoo.de]
> Sent: Wednesday, August 08, 2012 12:00 PM
> To: Venu Byravarasu
> Cc: linux-kernel@vger.kernel.org
> Subject: Re: question on devm_kfree
> 
> On 08/08/2012 07:56 AM, Venu Byravarasu wrote:
> > As per comments related to devm_kzalloc, memory allocated using it is
> > freed automatically.
> > However there is a function called devm_kfree, comment section of which
> > says that it is used to free memory allocated using devm_kzalloc().
> > If memory allocated by devm_kzalloc is freed automatically, what's the
> > need & significance of devm_kfree?
> >
> > Thanks,
> > Venu
> >
> 
> Hi,
> 
> Memory allocated with devm_kzalloc is freed at the end of the lifetime of the
> device it is attached to. If you for some reason want to free allocated with
> memory devm_kzalloc before that of the lifetime of the device can use
> devm_kfree.
> 
> 
> - Lars
 
Thanks Lars.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-08  6:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-08  5:56 question on devm_kfree Venu Byravarasu
2012-08-08  6:30 ` Lars-Peter Clausen
2012-08-08  6:38   ` Venu Byravarasu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox