[patch 02/16] Marker fix unregister

Mathieu Desnoyers
2008-11-14T23:03:05Z

[-- Attachment #1: markers-fix-unregister-private-data.patch --]
[-- Type: text/plain, Size: 1896 bytes --]

get_marker() can return a NULL entry because the mutex is released in the middle
of those functions. Make sure we check to see if it has been concurrently
removed.

Impact: Bugfix.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: Lai Jiangshan <laijs@cn.fujitsu.com>
---
kernel/marker.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

Index: linux.trees.git/kernel/marker.c
===================================================================
--- linux.trees.git.orig/kernel/marker.c 2008-11-14 17:38:39.000000000 -0500
+++ linux.trees.git/kernel/marker.c 2008-11-14 17:38:43.000000000 -0500
@@ -653,10 +653,11 @@ int marker_probe_register(const char *na
goto end;
}
mutex_unlock(&markers_mutex);
- marker_update_probes(); /* may update entry */
+ marker_update_probes();
mutex_lock(&markers_mutex);
entry = get_marker(name);
- WARN_ON(!entry);
+ if (!entry)
+ goto end;
if (entry->rcu_pending)
rcu_barrier_sched();
entry->oldptr = old;
@@ -697,7 +698,7 @@ int marker_probe_unregister(const char *
rcu_barrier_sched();
old = marker_entry_remove_probe(entry, probe, probe_private);
mutex_unlock(&markers_mutex);
- marker_update_probes(); /* may update entry */
+ marker_update_probes();
mutex_lock(&markers_mutex);
entry = get_marker(name);
if (!entry)
@@ -778,10 +779,11 @@ int marker_probe_unregister_private_data
rcu_barrier_sched();
old = marker_entry_remove_probe(entry, NULL, probe_private);
mutex_unlock(&markers_mutex);
- marker_update_probes(); /* may update entry */
+ marker_update_probes();
mutex_lock(&markers_mutex);
entry = get_marker_from_private_data(probe, probe_private);
- WARN_ON(!entry);
+ if (!entry)
+ goto end;
if (entry->rcu_pending)
rcu_barrier_sched();
entry->oldptr = old;