diff mbox

[linux-cifs-client,2/4] cifs: don't leave open files dangling

Message ID 1274466317-28231-3-git-send-email-jlayton@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton May 21, 2010, 6:25 p.m. UTC
None
diff mbox

Patch

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 54de8e5..e11ee2e 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -269,6 +269,8 @@  int cifs_posix_open(char *full_path, struct inode **pinode,
 					       oflags);
 		if (pfile_info == NULL)
 			rc = -ENOMEM;
+	} else {
+		CIFSSMBClose(xid, cifs_sb->tcon, *pnetfid);
 	}
 
 posix_open_ret:
@@ -478,11 +480,7 @@  cifs_create_set_dentry:
 	else
 		cFYI(1, "Create worked, get_inode_info failed rc = %d", rc);
 
-	/* nfsd case - nfs srv does not set nd */
-	if ((nd == NULL) || (!(nd->flags & LOOKUP_OPEN))) {
-		/* mknod case - do not leave file open */
-		CIFSSMBClose(xid, tcon, fileHandle);
-	} else if (!(posix_create) && (newinode)) {
+	if (!posix_create && newinode) {
 		struct cifsFileInfo *pfile_info;
 		/*
 		 * cifs_fill_filedata() takes care of setting cifsFileInfo
@@ -492,7 +490,10 @@  cifs_create_set_dentry:
 					       nd->path.mnt, oflags);
 		if (pfile_info == NULL)
 			rc = -ENOMEM;
+	} else {
+		CIFSSMBClose(xid, tcon, fileHandle);
 	}
+
 cifs_create_out:
 	kfree(buf);
 	kfree(full_path);