Skip to content

Commit

Permalink
driver core: prevent device_for_each_child from oopsing
Browse files Browse the repository at this point in the history
David Vrabel noticed that the wireless usb stack likes to call
device_for_each_chile() with an empty bus.  This used to work fine, but
now oopses.  This patch fixes the oops and makes the code behave like it
used to.

Reported-by: David Vrabel <david.vrabel@csr.com>
Tested-by: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed Apr 16, 2009
1 parent 4ccb457 commit 014c90d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,9 @@ int device_for_each_child(struct device *parent, void *data,
struct device *child;
int error = 0;

if (!parent->p)
return 0;

klist_iter_init(&parent->p->klist_children, &i);
while ((child = next_device(&i)) && !error)
error = fn(child, data);
Expand Down

0 comments on commit 014c90d

Please sign in to comment.