From: Zhang Xiaoxu Date: Mon, 17 Oct 2022 14:45:21 +0000 (+0800) Subject: cifs: Fix xid leak in cifs_create() X-Git-Tag: v6.0.6~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=92aa09c86ef297976a3c27c6574c0839418dc2c4;p=thirdparty%2Fkernel%2Fstable.git cifs: Fix xid leak in cifs_create() [ Upstream commit fee0fb1f15054bb6a0ede452acb42da5bef4d587 ] If the cifs already shutdown, we should free the xid before return, otherwise, the xid will be leaked. Fixes: 087f757b0129 ("cifs: add shutdown support") Reviewed-by: Paulo Alcantara (SUSE) Signed-off-by: Zhang Xiaoxu Signed-off-by: Steve French Signed-off-by: Sasha Levin --- diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 08f7392716e2f..05c78a18ade07 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -551,8 +551,10 @@ int cifs_create(struct user_namespace *mnt_userns, struct inode *inode, cifs_dbg(FYI, "cifs_create parent inode = 0x%p name is: %pd and dentry = 0x%p\n", inode, direntry, direntry); - if (unlikely(cifs_forced_shutdown(CIFS_SB(inode->i_sb)))) - return -EIO; + if (unlikely(cifs_forced_shutdown(CIFS_SB(inode->i_sb)))) { + rc = -EIO; + goto out_free_xid; + } tlink = cifs_sb_tlink(CIFS_SB(inode->i_sb)); rc = PTR_ERR(tlink);