All of lore.kernel.org
 help / color / mirror / Atom feed
* [Question: devm_kfree] When should devm_kfree() be used?
@ 2019-05-28  0:32 Gen Zhang
  2019-05-28  6:49 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Gen Zhang @ 2019-05-28  0:32 UTC (permalink / raw)
  To: gregkh, rafael, akpm; +Cc: linux-kernel

devm_kmalloc() is used to allocate memory for a driver dev. Comments
above the definition and doc 
(https://www.kernel.org/doc/Documentation/driver-model/devres.txt) all
imply that allocated the memory is automatically freed on driver attach,
no matter allocation fail or not. However, I examined the code, and
there are many sites that devm_kfree() is used to free devm_kmalloc().
e.g. hisi_sas_debugfs_init() in drivers/scsi/hisi_sas/hisi_sas_main.c.
So I am totally confused about this issue. Can anybody give me some
guidance? When should we use devm_kfree()?

Thanks

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

end of thread, other threads:[~2019-05-28 12:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-28  0:32 [Question: devm_kfree] When should devm_kfree() be used? Gen Zhang
2019-05-28  6:49 ` Greg KH
2019-05-28  7:14   ` Gen Zhang
2019-05-28 12:41     ` Greg KH
2019-05-28 12:47       ` Gen Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.