Skip to content

Commit 77577de

Browse files
sherllySteve French
authored and
Steve French
committed
cifs: Fix cached_fid refcnt leak in open_shroot
open_shroot() invokes kref_get(), which increases the refcount of the "tcon->crfid" object. When open_shroot() returns not zero, it means the open operation failed and close_shroot() will not be called to decrement the refcount of the "tcon->crfid". The reference counting issue happens in one normal path of open_shroot(). When the cached root have been opened successfully in a concurrent process, the function increases the refcount and jump to "oshr_free" to return. However the current return value "rc" may not equal to 0, thus the increased refcount will not be balanced outside the function, causing a refcnt leak. Fix this issue by setting the value of "rc" to 0 before jumping to "oshr_free" label. Signed-off-by: Xiyu Yang <[email protected]> Signed-off-by: Xin Tan <[email protected]> Signed-off-by: Steve French <[email protected]> CC: Stable <[email protected]>
1 parent 4877846 commit 77577de

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/cifs/smb2ops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon,
763763
/* close extra handle outside of crit sec */
764764
SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
765765
}
766+
rc = 0;
766767
goto oshr_free;
767768
}
768769

0 commit comments

Comments
 (0)