diff options
author | Hannes Reinecke <hare@suse.de> | 2012-04-16 09:06:25 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-04-18 18:39:52 -0400 |
commit | a15d49fd3094cff90e5410ca454a870e0a722fe1 (patch) | |
tree | f3e458fa4ce3524f756e0faa48d5ed2400c022bf /lib | |
parent | 97ec448aeadff55234368a89c4a07a7ef290a084 (diff) |
driver core: check start node in klist_iter_init_node
klist_iter_init_node() takes a node as a start argument.
However, this node might not be valid anymore.
This patch updates the klist_iter_init_node() and
dependent functions to return an error if so.
All calling functions have been audited to check
for a return code here.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Cc: Greg Kroah-Hartmann <gregkh@linuxfoundation.org>
Cc: Kay Sievers <kay@vrfy.org>
Cc: Stable Kernel <stable@kernel.org>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/klist.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/klist.c b/lib/klist.c index 0874e41609a6..a2741a7d9784 100644 --- a/lib/klist.c +++ b/lib/klist.c | |||
@@ -278,13 +278,19 @@ EXPORT_SYMBOL_GPL(klist_node_attached); | |||
278 | * Similar to klist_iter_init(), but starts the action off with @n, | 278 | * Similar to klist_iter_init(), but starts the action off with @n, |
279 | * instead of with the list head. | 279 | * instead of with the list head. |
280 | */ | 280 | */ |
281 | void klist_iter_init_node(struct klist *k, struct klist_iter *i, | 281 | int klist_iter_init_node(struct klist *k, struct klist_iter *i, |
282 | struct klist_node *n) | 282 | struct klist_node *n) |
283 | { | 283 | { |
284 | if (n) { | ||
285 | kref_get(&n->n_ref); | ||
286 | if (!n->n_klist) { | ||
287 | kref_put(&n->n_ref); | ||
288 | return -ENODEV; | ||
289 | } | ||
290 | } | ||
284 | i->i_klist = k; | 291 | i->i_klist = k; |
285 | i->i_cur = n; | 292 | i->i_cur = n; |
286 | if (n) | 293 | return 0; |
287 | kref_get(&n->n_ref); | ||
288 | } | 294 | } |
289 | EXPORT_SYMBOL_GPL(klist_iter_init_node); | 295 | EXPORT_SYMBOL_GPL(klist_iter_init_node); |
290 | 296 | ||