LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] cifs: dir: fix memory leak in cifs_mknod
@ 2018-04-20 13:19 Gustavo A. R. Silva
  2018-04-20 17:37 ` Steve French
  0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-04-20 13:19 UTC (permalink / raw)
  To: Ronnie Sahlberg, Steve French
  Cc: linux-cifs, samba-technical, linux-kernel, Gustavo A. R. Silva

Free allocated memory for full_path and xid before return.

Addresses-Coverity-ID: 1468029 ("Resource leak")
Fixes: 49162bfde140 ("cifs: do not allow creating sockets except with
SMB1 posix exensions")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 fs/cifs/dir.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index f0a759d..71e32d9 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -684,8 +684,11 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
 		goto mknod_out;
 	}
 
-	if (!S_ISCHR(mode) && !S_ISBLK(mode))
+	if (!S_ISCHR(mode) && !S_ISBLK(mode)) {
+		kfree(full_path);
+		free_xid(xid);
 		return -EPERM;
+	}
 
 	if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
 		goto mknod_out;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-20 18:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20 13:19 [PATCH] cifs: dir: fix memory leak in cifs_mknod Gustavo A. R. Silva
2018-04-20 17:37 ` Steve French
2018-04-20 17:48   ` Gustavo A. R. Silva
2018-04-20 18:02   ` Pavel Shilovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).