--- x/fs/namei.c +++ y/fs/namei.c @@ -3795,8 +3795,11 @@ static struct file *path_openat(struct n while (!(error = link_path_walk(s, nd)) && (s = open_last_lookups(nd, file, op)) != NULL) ; - if (!error) + if (!error) { + path_get(&nd->path); error = do_open(nd, file, op); + path_put(&nd->path); + } terminate_walk(nd); } if (likely(!error)) {