From: Gen Zhang <blackgod016574@gmail.com>
To: gregkh@linuxfoundation.org, rafael@kernel.org, akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Subject: [Question: devm_kfree] When should devm_kfree() be used?
Date: Tue, 28 May 2019 08:32:57 +0800 [thread overview]
Message-ID: <20190528003257.GA12065@zhanggen-UX430UQ> (raw)
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
next reply other threads:[~2019-05-28 0:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-28 0:32 Gen Zhang [this message]
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
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=20190528003257.GA12065@zhanggen-UX430UQ \
--to=blackgod016574@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/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
all inboxes | Powered by JetHome®