LKML Archive on
help / color / mirror / Atom feed
* [PATCH][next] cifs: ensure full_path is free'd on error exit path
@ 2018-04-20 13:15 Colin King
  0 siblings, 0 replies; only message in thread
From: Colin King @ 2018-04-20 13:15 UTC (permalink / raw)
  To: Steve French, linux-cifs, Ronnie Sahlberg, samba-technical
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <>

Currently the check on the mode flags that returns -EPERM is leaking
full_path on the error exit return. Fix this by kfree'ing it before
the return.

Detected by CoverityScan, CID#1468029 ("Resource Leak")

Fixes: 49162bfde140 ("cifs: do not allow creating sockets except with SMB1 posix exensions")
Signed-off-by: Colin Ian King <>
 fs/cifs/dir.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index f0a759dd6817..207883b39362 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -684,8 +684,10 @@ 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);
 		return -EPERM;
+	}
 	if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
 		goto mknod_out;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-04-20 13:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20 13:15 [PATCH][next] cifs: ensure full_path is free'd on error exit path Colin King

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).