From: Andy Shevchenko Date: Mon, 17 May 2021 12:29:45 +0000 (+0300) Subject: devres: No need to call remove_nodes() when there none present X-Git-Tag: v5.14-rc1~67^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7f1d03b6046cf44f1dd702aeaad3b5e4d7b33a5;p=thirdparty%2Fkernel%2Flinux.git devres: No need to call remove_nodes() when there none present If a list of devres nodes is empty, no need to call remove_nodes(). Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210517122946.53161-3-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/base/devres.c b/drivers/base/devres.c index db1f3137fc819..dee48858663f0 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -526,6 +526,10 @@ int devres_release_all(struct device *dev) if (WARN_ON(dev->devres_head.next == NULL)) return -ENODEV; + /* Nothing to release if list is empty */ + if (list_empty(&dev->devres_head)) + return 0; + spin_lock_irqsave(&dev->devres_lock, flags); cnt = remove_nodes(dev, dev->devres_head.next, &dev->devres_head, &todo); spin_unlock_irqrestore(&dev->devres_lock, flags);