diff options
author | Frank Pavlic <pavlic@de.ibm.com> | 2005-11-26 23:48:40 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-01-04 19:18:08 -0500 |
commit | e22dafbcd7a579c29a424d5203b5b33b131948a7 (patch) | |
tree | 122969a87ba706be8374beb15bc03493e3601404 | |
parent | bf74ad5bc41727d5f2f1c6bedb2c1fac394de731 (diff) |
[PATCH] klist: Fix broken kref counting in find functions
The klist reference counting in the find functions that use
klist_iter_init_node is broken. If the function (for example
driver_find_device) is called with a NULL start object then everything is
fine, the first call to next_device()/klist_next increases the ref-count of
the first node on the list and does nothing for the start object which is
NULL.
If they are called with a valid start object then klist_next will decrement
the ref-count for the start object but nobody has incremented it. Logical
place to fix this would be klist_iter_init_node because the function puts a
reference of the object into the klist_iter struct.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Frank Pavlic <pavlic@de.ibm.com>
Cc: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | lib/klist.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/klist.c b/lib/klist.c index bb2f3551d50a..9c94f0b163a1 100644 --- a/lib/klist.c +++ b/lib/klist.c | |||
@@ -199,6 +199,8 @@ void klist_iter_init_node(struct klist * k, struct klist_iter * i, struct klist_ | |||
199 | i->i_klist = k; | 199 | i->i_klist = k; |
200 | i->i_head = &k->k_list; | 200 | i->i_head = &k->k_list; |
201 | i->i_cur = n; | 201 | i->i_cur = n; |
202 | if (n) | ||
203 | kref_get(&n->n_ref); | ||
202 | } | 204 | } |
203 | 205 | ||
204 | EXPORT_SYMBOL_GPL(klist_iter_init_node); | 206 | EXPORT_SYMBOL_GPL(klist_iter_init_node); |