cifs: Fix missing error code set
authorDavid Howells <dhowells@redhat.com>
Thu, 18 Jul 2024 19:55:20 +0000 (20:55 +0100)
committerSteve French <stfrench@microsoft.com>
Fri, 19 Jul 2024 16:08:57 +0000 (11:08 -0500)
In cifs_strict_readv(), the default rc (-EACCES) is accidentally cleared by
a successful return from netfs_start_io_direct(), such that if
cifs_find_lock_conflict() fails, we don't return an error.

Fix this by resetting the default error code.

Fixes: 14b1cd25346b ("cifs: Fix locking in cifs_strict_readv()")
Cc: stable@vger.kernel.org
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-cifs@vger.kernel.org
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/file.c

index 1374635e89fae5e60f9ee6e8249f592a16f6b617..6178c6d8097d180fe0ecc2c2e0e5669e385688e9 100644 (file)
@@ -2877,6 +2877,7 @@ cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to)
                rc = netfs_start_io_direct(inode);
                if (rc < 0)
                        goto out;
+               rc = -EACCES;
                down_read(&cinode->lock_sem);
                if (!cifs_find_lock_conflict(
                            cfile, iocb->ki_pos, iov_iter_count(to),
@@ -2889,6 +2890,7 @@ cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to)
                rc = netfs_start_io_read(inode);
                if (rc < 0)
                        goto out;
+               rc = -EACCES;
                down_read(&cinode->lock_sem);
                if (!cifs_find_lock_conflict(
                            cfile, iocb->ki_pos, iov_iter_count(to),