[RHEL7,COMMIT] ms/NFS: Fix a double unlock from nfs_match, get_client

Submitted by Konstantin Khorenko on Oct. 3, 2019, 3:47 p.m.


Message ID 201910031547.x93FlLZo011397@finist-ce7.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko Oct. 3, 2019, 3:47 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.27.2.vz7.107.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.27.2.vz7.107.13
commit d4437785bd5ab9972892765287b64d03a984c6cc
Author: Benjamin Coddington <bcodding@redhat.com>
Date:   Thu Oct 3 18:47:21 2019 +0300

    ms/NFS: Fix a double unlock from nfs_match,get_client
    Now that nfs_match_client drops the nfs_client_lock, we should be
    careful to always return it in the same condition: locked.
    Fixes: 950a578c6128 ("NFS: make nfs_match_client killable")
    Reported-by: syzbot+228a82b263b5da91883d@syzkaller.appspotmail.com
    Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    (cherry picked from commit c260121a97a3e4df6536edbc2f26e166eff370ce)
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
 fs/nfs/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 24d025fcbb6a..72ddd88a2f2f 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -310,9 +310,9 @@  static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
 			error = nfs_wait_client_init_complete(clp);
+			spin_lock(&nn->nfs_client_lock);
 			if (error < 0)
 				return ERR_PTR(error);
-			spin_lock(&nn->nfs_client_lock);
 			goto again;