diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c
index 97a916ea8b86ab89390ec1fe6dd25043d74e8212..87bd4148f4fb5811547fa2b44a7965af7f22e52a 100644
--- a/fs/overlayfs/export.c
+++ b/fs/overlayfs/export.c
@@ -620,7 +620,7 @@ static struct dentry *ovl_lookup_real(struct super_block *sb,
 			if (err == -ECHILD) {
 				this = ovl_lookup_real_ancestor(sb, real,
 								layer);
-				err = IS_ERR(this) ? PTR_ERR(this) : 0;
+				err = PTR_ERR_OR_ZERO(this);
 			}
 			if (!err) {
 				dput(connected);