From: Khaled ROMDHANI Date: Tue, 4 May 2021 15:38:55 +0000 (+0100) Subject: fs/cifs: Fix resource leak X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=bae4c0c1c2d576d32e37925ef972a5d45f34e36d;p=linux.git fs/cifs: Fix resource leak The -EIO error return path is leaking memory allocated to page. Fix this by moving the allocation block after the check of cifs_forced_shutdown. Addresses-Coverity: ("Resource leak") Fixes: 087f757b0129 ("cifs: add shutdown support") Signed-off-by: Khaled ROMDHANI Reviewed-by: Dan Carpenter Signed-off-by: Steve French --- diff --git a/fs/cifs/link.c b/fs/cifs/link.c index 1cbe7ec737283..970fcf2adb08c 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c @@ -683,12 +683,16 @@ cifs_symlink(struct user_namespace *mnt_userns, struct inode *inode, struct tcon_link *tlink; struct cifs_tcon *pTcon; const char *full_path; - void *page = alloc_dentry_path(); + void *page; struct inode *newinode = NULL; if (unlikely(cifs_forced_shutdown(cifs_sb))) return -EIO; + page = alloc_dentry_path(); + if (!page) + return -ENOMEM; + xid = get_xid(); tlink = cifs_sb_tlink(cifs_sb);