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

Message ID 20190815121555.15825-1-jlayton@kernel.org
State New
Headers show
Series
  • ceph: don't try fill file_lock on unsuccessful GETFILELOCK reply
Related show

Commit Message

Jeff Layton Aug. 15, 2019, 12:15 p.m. UTC
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>
---
 fs/ceph/locks.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Yan, Zheng Aug. 15, 2019, 12:51 p.m. UTC | #1
On Thu, Aug 15, 2019 at 8:15 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> 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>
> ---
>  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 cb216501c959..544e9e85b120 100644
> --- a/fs/ceph/locks.c
> +++ b/fs/ceph/locks.c
> @@ -115,8 +115,7 @@ static int ceph_lock_message(u8 lock_type, u16 operation, struct inode *inode,
>                 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;
> --
> 2.21.0
>

Reviewed by

Patch
diff mbox series

diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index cb216501c959..544e9e85b120 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -115,8 +115,7 @@  static int ceph_lock_message(u8 lock_type, u16 operation, struct inode *inode,
 		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;