[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190528003257.GA12065@zhanggen-UX430UQ>
Date: Tue, 28 May 2019 08:32:57 +0800
From: Gen Zhang <blackgod016574@...il.com>
To: gregkh@...uxfoundation.org, rafael@...nel.org,
akpm@...ux-foundation.org
Cc: linux-kernel@...r.kernel.org
Subject: [Question: devm_kfree] When should devm_kfree() be used?
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
Powered by blists - more mailing lists