From 93ead7c9483c6d7ae0f67ae6d0a5d3966d84bec8 Mon Sep 17 00:00:00 2001 From: Gimcuan Hui Date: Sat, 11 Nov 2017 05:52:54 +0000 Subject: drivers: base: omit redundant interations When error happens, these interators return the error, no interation should be continued, so make the change for getting out of while immediately. Signed-off-by: Gimcuan Hui Signed-off-by: Greg Kroah-Hartman --- drivers/base/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/base/bus.c') diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 6c63e1abbdcc..ef6183306b40 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -307,7 +307,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start, klist_iter_init_node(&bus->p->klist_devices, &i, (start ? &start->p->knode_bus : NULL)); - while ((dev = next_device(&i)) && !error) + while (!error && (dev = next_device(&i))) error = fn(dev, data); klist_iter_exit(&i); return error; -- cgit v1.2.3