Merge tag 'io_uring-5.9-2020-08-28' of git://git.kernel.dk/linux-block
[linux-2.6-microblaze.git] / fs / namei.c
index fb318e0..e99e2a9 100644 (file)
@@ -2849,8 +2849,10 @@ static int may_open(const struct path *path, int acc_mode, int flag)
        case S_IFLNK:
                return -ELOOP;
        case S_IFDIR:
-               if (acc_mode & (MAY_WRITE | MAY_EXEC))
+               if (acc_mode & MAY_WRITE)
                        return -EISDIR;
+               if (acc_mode & MAY_EXEC)
+                       return -EACCES;
                break;
        case S_IFBLK:
        case S_IFCHR:
@@ -3776,11 +3778,11 @@ exit2:
        mnt_drop_write(path.mnt);
 exit1:
        path_put(&path);
-       putname(name);
        if (retry_estale(error, lookup_flags)) {
                lookup_flags |= LOOKUP_REVAL;
                goto retry;
        }
+       putname(name);
        return error;
 }