aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>2020-02-13 18:23:11 +0530
committerJonathan Corbet <corbet@lwn.net>2020-02-25 03:39:10 -0700
commitef45e78fdc11ac1794940c2ff4a6bf3bc4c45372 (patch)
tree657c4f117352dfcbeb379b0529d76fa6b8398398
parentdocs: add a script to check sysctl docs (diff)
downloadlinux-dev-ef45e78fdc11ac1794940c2ff4a6bf3bc4c45372.tar.xz
linux-dev-ef45e78fdc11ac1794940c2ff4a6bf3bc4c45372.zip
docs: kref: Clarify the use of two kref_put() in example code
Eventhough the current documentation explains that the reference count gets incremented by both kref_init() and kref_get(), it is often misunderstood that only one instance of kref_put() is needed in the example code. So let's clarify that a bit. Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
-rw-r--r--Documentation/kref.txt4
1 files changed, 4 insertions, 0 deletions
diff --git a/Documentation/kref.txt b/Documentation/kref.txt
index 3af384156d7e..c61eea6f1bf2 100644
--- a/Documentation/kref.txt
+++ b/Documentation/kref.txt
@@ -128,6 +128,10 @@ since we already have a valid pointer that we own a refcount for. The
put needs no lock because nothing tries to get the data without
already holding a pointer.
+In the above example, kref_put() will be called 2 times in both success
+and error paths. This is necessary because the reference count got
+incremented 2 times by kref_init() and kref_get().
+
Note that the "before" in rule 1 is very important. You should never
do something like::