struct path path;
int error;
unsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
- struct filename *name = getname(filename);
+ CLASS(filename, name)(filename);
retry:
error = filename_lookup(AT_FDCWD, name, lookup_flags, &path, NULL);
- if (error)
- goto out;
-
- error = path_permission(&path, MAY_EXEC | MAY_CHDIR);
- if (error)
- goto dput_and_out;
-
- set_fs_pwd(current->fs, &path);
-
-dput_and_out:
- path_put(&path);
- if (retry_estale(error, lookup_flags)) {
- lookup_flags |= LOOKUP_REVAL;
- goto retry;
+ if (!error) {
+ error = path_permission(&path, MAY_EXEC | MAY_CHDIR);
+ if (!error)
+ set_fs_pwd(current->fs, &path);
+ path_put(&path);
+ if (retry_estale(error, lookup_flags)) {
+ lookup_flags |= LOOKUP_REVAL;
+ goto retry;
+ }
}
-out:
- putname(name);
return error;
}