From: Nicholas Mc Guire <hofrat@osadl.org>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Philippe Ombredanne <pombredanne@nexb.com>,
Andrey Smirnov <andrew.smirnov@gmail.com>,
Uwe Kleine-Knig <u.kleine-koenig@pengutronix.de>,
Linus Walleij <linus.walleij@linaro.org>,
Huang Shijie <sjhuang@iluvatar.ai>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Nicholas Mc Guire <hofrat@osadl.org>
Subject: [PATCH] Documentation: devres: note checking needs when converting
Date: Sat, 1 Dec 2018 13:44:29 +0100 [thread overview]
Message-ID: <1543668269-27207-1-git-send-email-hofrat@osadl.org> (raw)
There are a number of cases where conversions to devm_* API have been
done but developers forgot that this conversion may imply that return
values need to be checked for failure of internal resource handling
like allocation. While this should be clear, it does seem to be a
relatively common issue with API conversions or maybe "managed" is
being misunderstood ? So add a note to make the scope of "managed" clear.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
This popped up due to some API checking coccinelle scripts for devm_* that are
under development are triggering far to often - checking devm_kasprintf flagged
16 of the 132, 14 of which are true-positives (11%) and for the 33 devm_kstrdup
cases 8 look buggy (missing check for return NULL) thats 24%. Others seem to be
related to simple replacement of previous assignments to devm_* calls - so
given this high number of incorrect use the root-cause may be a misunderstanding
of "managed", which it seems was not being clearly understood as only addressing
freeing.
Not sure if the wording here is clear enough - but some clarification to this
ends seems needed.
Patch is against 4.20-rc4 (localversion-next is next-20181130)
Documentation/driver-model/devres.txt | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 48aa1ef..ea2532b 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -132,6 +132,13 @@ devres. Complexity is shifted from less maintained low level drivers
to better maintained higher layer. Also, as init failure path is
shared with exit path, both can get more testing.
+Note though that when converting current calls or assignments to
+managed devm_* versions it is up to you to check if internal operations
+like allocating memory, have failed. Managed resources pertains to the
+freeing of these resources *only* - all other checks needed are still
+on you. In some cases this may mean introducing checks that were not
+necessary before moving to the managed devm_* calls.
+
3. Devres group
---------------
--
2.1.4
next reply other threads:[~2018-12-01 12:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-01 12:44 Nicholas Mc Guire [this message]
2018-12-06 17:14 ` Jonathan Corbet
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=1543668269-27207-1-git-send-email-hofrat@osadl.org \
--to=hofrat@osadl.org \
--cc=andrew.smirnov@gmail.com \
--cc=corbet@lwn.net \
--cc=linus.walleij@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pombredanne@nexb.com \
--cc=sjhuang@iluvatar.ai \
--cc=u.kleine-koenig@pengutronix.de \
/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®