mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
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 <[email protected]> Cc: Greg Kroah-Hartmann <[email protected]> Cc: Kay Sievers <[email protected]> Cc: Stable Kernel <[email protected]> Cc: Linux Kernel <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
97ec448aea
commit
a15d49fd30
6 changed files with 76 additions and 46 deletions
14
lib/klist.c
14
lib/klist.c
|
|
@ -278,13 +278,19 @@ EXPORT_SYMBOL_GPL(klist_node_attached);
|
|||
* Similar to klist_iter_init(), but starts the action off with @n,
|
||||
* instead of with the list head.
|
||||
*/
|
||||
void klist_iter_init_node(struct klist *k, struct klist_iter *i,
|
||||
struct klist_node *n)
|
||||
int klist_iter_init_node(struct klist *k, struct klist_iter *i,
|
||||
struct klist_node *n)
|
||||
{
|
||||
if (n) {
|
||||
kref_get(&n->n_ref);
|
||||
if (!n->n_klist) {
|
||||
kref_put(&n->n_ref);
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
i->i_klist = k;
|
||||
i->i_cur = n;
|
||||
if (n)
|
||||
kref_get(&n->n_ref);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(klist_iter_init_node);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue