ceph: don’t try fill file_lock on unsuccessful GETFILELOCK reply [Linux 4.14.141]

This Linux kernel change "ceph: don’t try fill file_lock on unsuccessful GETFILELOCK reply" is included in the Linux 4.14.141 release. This change is authored by Jeff Layton <jlayton [at] kernel.org> on Thu Aug 15 06:23:38 2019 -0400. The commit for this change in Linux stable tree is e6a1bf1 (patch) which is from upstream commit 28a2826. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 28a2826.

ceph: don't try fill file_lock on unsuccessful GETFILELOCK reply

commit 28a282616f56990547b9dcd5c6fbd2001344664c upstream.

When ceph_mdsc_do_request returns an error, we can't assume that the
filelock_reply pointer will be set. Only try to fetch fields out of
the r_reply_info when it returns success.

Cc: stable@vger.kernel.org
Reported-by: Hector Martin <hector@marcansoft.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 fs/ceph/locks.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index e7cce41..cb647c8 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -78,8 +78,7 @@ static int ceph_lock_message(u8 lock_type, u16 operation, struct file *file,
        req->r_wait_for_completion = ceph_lock_wait_for_completion;

    err = ceph_mdsc_do_request(mdsc, inode, req);
-
-   if (operation == CEPH_MDS_OP_GETFILELOCK) {
+   if (!err && operation == CEPH_MDS_OP_GETFILELOCK) {
        fl->fl_pid = -le64_to_cpu(req->r_reply_info.filelock_reply->pid);
        if (CEPH_LOCK_SHARED == req->r_reply_info.filelock_reply->type)
            fl->fl_type = F_RDLCK;

Leave a Reply

Your email address will not be published. Required fields are marked *