public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] doc/RCU/listRCU: fix an example code snippets
@ 2025-01-01  8:23 Wei Yang
  2025-01-23  1:48 ` Wei Yang
  2025-02-17  2:12 ` Boqun Feng
  0 siblings, 2 replies; 10+ messages in thread
From: Wei Yang @ 2025-01-01  8:23 UTC (permalink / raw)
  To: paulmck, frederic, neeraj.upadhyay; +Cc: rcu, linux-doc, Wei Yang

The example code for "Eliminating Stale Data" looks not correct:

  * rcu_read_unlock() should put after kstrdup()
  * spin_unlock() should be called before return

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>

---
Hope my understanding is correct.
---
 Documentation/RCU/listRCU.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/RCU/listRCU.rst b/Documentation/RCU/listRCU.rst
index ed5c9d8c9afe..8df50fcd69fd 100644
--- a/Documentation/RCU/listRCU.rst
+++ b/Documentation/RCU/listRCU.rst
@@ -348,9 +348,10 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 					rcu_read_unlock();
 					return AUDIT_BUILD_CONTEXT;
 				}
-				rcu_read_unlock();
 				if (state == AUDIT_STATE_RECORD)
 					*key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+				spin_unlock(&e->lock);
+				rcu_read_unlock();
 				return state;
 			}
 		}
-- 
2.34.1


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

end of thread, other threads:[~2025-02-18  0:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-01  8:23 [PATCH] doc/RCU/listRCU: fix an example code snippets Wei Yang
2025-01-23  1:48 ` Wei Yang
2025-02-17  2:12 ` Boqun Feng
2025-02-17  2:22   ` Alan Huang
2025-02-17  2:35     ` Boqun Feng
2025-02-17  7:41     ` Wei Yang
2025-02-17  8:02       ` Alan Huang
2025-02-17  9:18         ` Wei Yang
2025-02-17 22:30           ` Boqun Feng
2025-02-18  0:25             ` Wei Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox