diff --git a/fs/namei.c b/fs/namei.c index d729ef7cbf46..99374704c17d 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1792,7 +1792,9 @@ static int link_path_walk(const char *name, struct nameidata *nd) if (unlikely(IS_ERR(s))) { err = PTR_ERR(s); - break; + current->link_count--; + nd->depth--; + return err; } err = 0; if (likely(s)) {