Patch "NFSv4.2: fix reference count leaks in _nfs42_proc_copy_notify()" has been added to the 5.16-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    NFSv4.2: fix reference count leaks in _nfs42_proc_copy_notify()

to the 5.16-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nfsv4.2-fix-reference-count-leaks-in-_nfs42_proc_cop.patch
and it can be found in the queue-5.16 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8cd3377e44bb310723fa978a9d667f269a67484b
Author: Xin Xiong <xiongx18@xxxxxxxxxxxx>
Date:   Tue Jan 25 21:10:45 2022 +0800

    NFSv4.2: fix reference count leaks in _nfs42_proc_copy_notify()
    
    [ Upstream commit b7f114edd54326f730a754547e7cfb197b5bc132 ]
    
    [You don't often get email from xiongx18@xxxxxxxxxxxx. Learn why this is important at http://aka.ms/LearnAboutSenderIdentification.]
    
    The reference counting issue happens in two error paths in the
    function _nfs42_proc_copy_notify(). In both error paths, the function
    simply returns the error code and forgets to balance the refcount of
    object `ctx`, bumped by get_nfs_open_context() earlier, which may
    cause refcount leaks.
    
    Fix it by balancing refcount of the `ctx` object before the function
    returns in both error paths.
    
    Signed-off-by: Xin Xiong <xiongx18@xxxxxxxxxxxx>
    Signed-off-by: Xiyu Yang <xiyuyang19@xxxxxxxxxxxx>
    Signed-off-by: Xin Tan <tanxin.ctf@xxxxxxxxx>
    Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 8b21ff1be717..438de4f93ce7 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -592,8 +592,10 @@ static int _nfs42_proc_copy_notify(struct file *src, struct file *dst,
 
 	ctx = get_nfs_open_context(nfs_file_open_context(src));
 	l_ctx = nfs_get_lock_context(ctx);
-	if (IS_ERR(l_ctx))
-		return PTR_ERR(l_ctx);
+	if (IS_ERR(l_ctx)) {
+		status = PTR_ERR(l_ctx);
+		goto out;
+	}
 
 	status = nfs4_set_rw_stateid(&args->cna_src_stateid, ctx, l_ctx,
 				     FMODE_READ);
@@ -601,7 +603,7 @@ static int _nfs42_proc_copy_notify(struct file *src, struct file *dst,
 	if (status) {
 		if (status == -EAGAIN)
 			status = -NFS4ERR_BAD_STATEID;
-		return status;
+		goto out;
 	}
 
 	status = nfs4_call_sync(src_server->client, src_server, &msg,
@@ -610,6 +612,7 @@ static int _nfs42_proc_copy_notify(struct file *src, struct file *dst,
 	if (status == -ENOTSUPP)
 		src_server->caps &= ~NFS_CAP_COPY_NOTIFY;
 
+out:
 	put_nfs_open_context(nfs_file_open_context(src));
 	return status;
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux