diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 880e89c894f6..e353b822bb15 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1805,12 +1805,12 @@ static struct class net_class __ro_after_init = { #ifdef CONFIG_OF_NET static int of_dev_node_match(struct device *dev, const void *data) { - int ret = 0; + for (; dev; dev = dev->parent) { + if (dev->of_node == data) + return 1; + } - if (dev->parent) - ret = dev->parent->of_node == data; - - return ret == 0 ? dev->of_node == data : ret; + return 0; } /*