瀏覽代碼

driver core: prevent device_for_each_child from oopsing

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>
Greg Kroah-Hartman 16 年之前
父節點
當前提交
014c90dbb9
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      drivers/base/core.c

+ 3 - 0
drivers/base/core.c

@@ -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);