Index: novfs/file.c
===================================================================
--- novfs.orig/file.c
+++ novfs/file.c
@@ -414,7 +414,7 @@ int novfs_listx_file_info(char *Path, ch
 
 	*dataLen = 0;
 	cmdlen = offsetof(struct novfs_verify_file_request, path) + pathlen;
-	cmd = (struct novfs_verify_file_request *)kmalloc(cmdlen, GFP_KERNEL);
+	cmd = (struct novfs_verify_file_request *) kmalloc(cmdlen + 1, GFP_KERNEL);
 	if (cmd) {
 		cmd->Command.CommandType = VFS_COMMAND_LIST_EXTENDED_ATTRIBUTES;
 		cmd->Command.SequenceNumber = 0;
Index: novfs/inode.c
===================================================================
--- novfs.orig/inode.c
+++ novfs/inode.c
@@ -337,9 +337,10 @@ int novfs_remove_from_root(char *RemoveN
 
 	dir = novfs_root->d_inode;
 
-	novfs_lock_inode_cache(dir);
-	novfs_remove_inode_entry(dir, &name, 0);
-	novfs_unlock_inode_cache(dir);
+	if (novfs_lock_inode_cache(dir)) {
+		novfs_remove_inode_entry(dir, &name, 0);
+		novfs_unlock_inode_cache(dir);
+	}
 
 	return (0);
 }
@@ -359,21 +360,21 @@ int novfs_add_to_root(char *AddName)
 
 	dir = novfs_root->d_inode;
 
-	novfs_lock_inode_cache(dir);
+	if (novfs_lock_inode_cache(dir)) {
+		ino = 0;
 
-	ino = 0;
+		if (!novfs_lookup_inode_cache(dir, &name, 0)) {
+			info.mode = S_IFDIR | 0700;
+			info.size = 0;
+			info.atime = info.ctime = info.mtime = CURRENT_TIME;
 
-	if (!novfs_lookup_inode_cache(dir, &name, 0)) {
-		info.mode = S_IFDIR | 0700;
-		info.size = 0;
-		info.atime = info.ctime = info.mtime = CURRENT_TIME;
+			ino = (ino_t) atomic_inc_return(&novfs_Inode_Number);
+			novfs_add_inode_entry(dir, &name, ino, &info);
+		}
 
-		ino = (ino_t) atomic_inc_return(&novfs_Inode_Number);
-		novfs_add_inode_entry(dir, &name, ino, &info);
+		novfs_unlock_inode_cache(dir);
 	}
 
-	novfs_unlock_inode_cache(dir);
-
 	return (0);
 }
 
@@ -510,6 +511,7 @@ int verify_dentry(struct dentry *dentry,
 					}
 				}
 				novfs_unlock_inode_cache(dir);
+				iLock = 0;
 			}
 
 			if (IS_ROOT(dentry->d_parent)) {
@@ -530,26 +532,28 @@ int verify_dentry(struct dentry *dentry,
 				list = novfs_get_scopeusers();
 
 				iLock = novfs_lock_inode_cache(dir);
-				novfs_invalidate_inode_cache(dir);
+				if (iLock) {
+					novfs_invalidate_inode_cache(dir);
 
-				if (list) {
-					cp = list;
-					while (*cp) {
-						name.name = cp;
-						name.len = strlen(cp);
-						name.hash = novfs_internal_hash(&name);
-						cp += (name.len + 1);
-						ino = 0;
-						if (novfs_get_entry(dir, &name, &ino, info)) {
-							info->mode = S_IFDIR | 0700;
-							info->size = 0;
-							info->atime = info->ctime = info->mtime = CURRENT_TIME;
-							ino = (ino_t) atomic_inc_return(&novfs_Inode_Number);
-							novfs_add_inode_entry(dir, &name, ino, info);
+					if (list) {
+						cp = list;
+						while (*cp) {
+							name.name = cp;
+							name.len = strlen(cp);
+							name.hash = novfs_internal_hash(&name);
+							cp += (name.len + 1);
+							ino = 0;
+							if (novfs_get_entry(dir, &name, &ino, info)) {
+								info->mode = S_IFDIR | 0700;
+								info->size = 0;
+								info->atime = info->ctime = info->mtime = CURRENT_TIME;
+								ino = (ino_t) atomic_inc_return(&novfs_Inode_Number);
+								novfs_add_inode_entry(dir, &name, ino, info);
+							}
 						}
 					}
+					novfs_free_invalid_entries(dir);
 				}
-				novfs_free_invalid_entries(dir);
 			} else {
 
 				path = novfs_dget_path(dentry, info->name, PATH_LENGTH_BUFFER);
@@ -563,13 +567,15 @@ int verify_dentry(struct dentry *dentry,
 						if (0 == retVal) {
 							dentry->d_time = jiffies + (novfs_update_timeout * HZ);
 							iLock = novfs_lock_inode_cache(dir);
-							if (novfs_update_entry(dir, &name, 0, info)) {
-								if (dentry->d_inode) {
-									ino = dentry->d_inode->i_ino;
-								} else {
-									ino = (ino_t) atomic_inc_return(&novfs_Inode_Number);
+							if (iLock) {
+								if (novfs_update_entry(dir, &name, 0, info)) {
+									if (dentry->d_inode) {
+										ino = dentry->d_inode->i_ino;
+									} else {
+										ino = (ino_t) atomic_inc_return(&novfs_Inode_Number);
+									}
+									novfs_add_inode_entry(dir, &name, ino, info);
 								}
-								novfs_add_inode_entry(dir, &name, ino, info);
 							}
 							if (dentry->d_inode) {
 								update_inode(dentry->d_inode, info);
@@ -584,18 +590,20 @@ int verify_dentry(struct dentry *dentry,
 						} else if (-EINTR != retVal) {
 							retVal = 0;
 							iLock = novfs_lock_inode_cache(dir);
-							novfs_remove_inode_entry(dir, &name, 0);
-							if (dentry->d_inode && !(dentry->d_inode->i_flags & S_DEAD)) {
-								dentry->d_inode->i_flags |= S_DEAD;
-								dentry->d_inode->i_size = 0;
-								dentry->d_inode->i_atime.tv_sec =
-								    dentry->d_inode->i_atime.tv_nsec =
-								    dentry->d_inode->i_ctime.tv_sec =
-								    dentry->d_inode->i_ctime.tv_nsec =
-								    dentry->d_inode->i_mtime.tv_sec =
-								    dentry->d_inode->i_mtime.tv_nsec = 0;
-								dentry->d_inode->i_blocks = 0;
-								d_delete(dentry);	/* Remove from cache */
+							if (iLock) {
+								novfs_remove_inode_entry(dir, &name, 0);
+								if (dentry->d_inode && !(dentry->d_inode->i_flags & S_DEAD)) {
+									dentry->d_inode->i_flags |= S_DEAD;
+									dentry->d_inode->i_size = 0;
+									dentry->d_inode->i_atime.tv_sec =
+									    dentry->d_inode->i_atime.tv_nsec =
+									    dentry->d_inode->i_ctime.tv_sec =
+									    dentry->d_inode->i_ctime.tv_nsec =
+									    dentry->d_inode->i_mtime.tv_sec =
+									    dentry->d_inode->i_mtime.tv_nsec = 0;
+									dentry->d_inode->i_blocks = 0;
+									d_delete(dentry);	/* Remove from cache */
+								}
 							}
 						}
 					} else {
@@ -978,18 +986,18 @@ void processList(struct file *file, void
 			cp += (name.len + 1);
 
 			pinfo = kmalloc(sizeof(struct novfs_entry_info) + PATH_LENGTH_BUFFER, GFP_KERNEL);
-			pinfo->mode = S_IFDIR | 0700;
-			pinfo->size = 0;
-			pinfo->atime = pinfo->ctime = pinfo->mtime = CURRENT_TIME;
-			strcpy(pinfo->name, name.name);
-			pinfo->namelength = name.len;
-
-			novfs_Dump_Info(pinfo);
+			if (pinfo) {
+				pinfo->mode = S_IFDIR | 0700;
+				pinfo->size = 0;
+				pinfo->atime = pinfo->ctime = pinfo->mtime = CURRENT_TIME;
+				strcpy(pinfo->name, name.name);
+				pinfo->namelength = name.len;
+				novfs_Dump_Info(pinfo);
+				kfree(pinfo);
+			}
 
-			filldir(dirent, pinfo->name, pinfo->namelength, file->f_pos, file->f_pos, pinfo->mode >> 12);
+			filldir(dirent, name.name, name.len, file->f_pos, file->f_pos, (S_IFDIR | 0700) >> 12);
 			file->f_pos += 1;
-
-			kfree(pinfo);
 		}
 	}
 
@@ -1349,13 +1357,13 @@ int novfs_f_open(struct inode *inode, st
 
 					if (parent && parent->d_inode) {
 						struct inode *dir = parent->d_inode;
-						novfs_lock_inode_cache(dir);
-						ino = 0;
-						if (novfs_get_entry(dir, &file->f_dentry->d_name, &ino, info)) {
-							((struct inode_data *)inode->i_private)->Flags |= UPDATE_INODE;
+						if (novfs_lock_inode_cache(dir)) {
+							ino = 0;
+							if (novfs_get_entry(dir, &file->f_dentry->d_name, &ino, info)) {
+								((struct inode_data *)inode->i_private)->Flags |= UPDATE_INODE;
+							}
+							novfs_unlock_inode_cache(dir);
 						}
-
-						novfs_unlock_inode_cache(dir);
 					}
 					dput(parent);
 				}
@@ -2525,7 +2533,10 @@ int novfs_i_unlink(struct inode *dir, st
 						}
 					}
 					if (!retCode || IS_DEADDIR(inode)) {
-						novfs_remove_inode_entry(dir, &dentry->d_name, 0);
+						if (novfs_lock_inode_cache(dir)) {
+							novfs_remove_inode_entry(dir, &dentry->d_name, 0);
+							novfs_unlock_inode_cache(dir);
+						}
 						dentry->d_time = 0;
 						t64 = 0;
 						novfs_scope_set_userspace(&t64, &t64, &t64, &t64);
@@ -2587,11 +2598,12 @@ int novfs_i_mkdir(struct inode *dir, str
 
 							dentry->d_time = jiffies + (novfs_update_timeout * HZ);
 
-							novfs_lock_inode_cache(dir);
-							if (novfs_update_entry(dir, &dentry->d_name, 0, &info)) {
-								novfs_add_inode_entry(dir, &dentry->d_name, inode->i_ino, &info);
+							if (novfs_lock_inode_cache(dir)) {
+								if (novfs_update_entry(dir, &dentry->d_name, 0, &info)) {
+									novfs_add_inode_entry(dir, &dentry->d_name, inode->i_ino, &info);
+								}
+								novfs_unlock_inode_cache(dir);
 							}
-							novfs_unlock_inode_cache(dir);
 						}
 
 					}
@@ -2637,9 +2649,10 @@ int novfs_i_mknod(struct inode *dir, str
 		novfs_d_add(parent, dentry, inode, 0);
 		memset(&info, 0, sizeof(info));
 		info.mode = inode->i_mode;
-		novfs_lock_inode_cache(dir);
-		novfs_add_inode_entry(dir, &dentry->d_name, inode->i_ino, &info);
-		novfs_unlock_inode_cache(dir);
+		if (novfs_lock_inode_cache(dir)) {
+			novfs_add_inode_entry(dir, &dentry->d_name, inode->i_ino, &info);
+			novfs_unlock_inode_cache(dir);
+		}
 
 		dput(parent);
 
@@ -2752,17 +2765,23 @@ int novfs_i_rename(struct inode *odir, s
 							if (!retCode) {
 								info = (struct novfs_entry_info *)oldbuf;
 								od->d_time = 0;
-								novfs_remove_inode_entry(odir, &od->d_name, 0);
-								novfs_remove_inode_entry(ndir, &nd->d_name, 0);
-								novfs_get_file_info(newpath, info, session);
-								nd->d_time = jiffies + (novfs_update_timeout * HZ);
-
-								if (od->d_inode && od->d_inode->i_ino) {
-									ino = od->d_inode->i_ino;
-								} else {
-									ino = (ino_t) atomic_inc_return(&novfs_Inode_Number);
+								if (novfs_lock_inode_cache(odir)) {
+									novfs_remove_inode_entry(odir, &od->d_name, 0);
+									novfs_unlock_inode_cache(odir);
+								}
+								if (novfs_lock_inode_cache(ndir)) {
+									novfs_remove_inode_entry(ndir, &nd->d_name, 0);
+									novfs_get_file_info(newpath, info, session);
+									nd->d_time = jiffies + (novfs_update_timeout * HZ);
+
+									if (od->d_inode && od->d_inode->i_ino) {
+										ino = od->d_inode->i_ino;
+									} else {
+										ino = (ino_t) atomic_inc_return(&novfs_Inode_Number);
+									}
+									novfs_add_inode_entry(ndir, &nd->d_name, ino, info);
+									novfs_unlock_inode_cache(ndir);
 								}
-								novfs_add_inode_entry(ndir, &nd->d_name, ino, info);
 							}
 						}
 					}
@@ -2850,8 +2869,8 @@ int novfs_i_setattr(struct dentry *dentr
 					}
 				}
 			}
+			kfree(buf);
 		}
-		kfree(buf);
 	}
 	DbgPrint("return 0x%x", retVal);
 
@@ -3162,7 +3181,10 @@ void novfs_evict_inode(struct inode *ino
 
 		DbgPrint("inode=0x%p ino=%d Scope=0x%p Name=%s", inode, inode->i_ino, id->Scope, id->Name);
 
-		novfs_free_inode_cache(inode);
+		if (novfs_lock_inode_cache(inode)) {
+			novfs_free_inode_cache(inode);
+			novfs_unlock_inode_cache(inode);
+		}
 
 		mutex_lock(&InodeList_lock);
 		list_del(&id->IList);
@@ -3407,7 +3429,10 @@ int novfs_fill_super(struct super_block
 				server->d_time = 0xffffffff;
 				d_add(server, inode);
 				DbgPrint("d_add %s 0x%p", SERVER_DIRECTORY_NAME, server);
-				novfs_add_inode_entry(novfs_root->d_inode, &name, inode->i_ino, &info);
+				if (novfs_lock_inode_cache(novfs_root->d_inode)) {
+					novfs_add_inode_entry(novfs_root->d_inode, &name, inode->i_ino, &info);
+					novfs_unlock_inode_cache(novfs_root->d_inode);
+				}
 			}
 		}
 
@@ -3430,7 +3455,10 @@ int novfs_fill_super(struct super_block
 
 				d_add(tree, inode);
 				DbgPrint("d_add %s 0x%p", TREE_DIRECTORY_NAME, tree);
-				novfs_add_inode_entry(novfs_root->d_inode, &name, inode->i_ino, &info);
+				if (novfs_lock_inode_cache(novfs_root->d_inode)) {
+					novfs_add_inode_entry(novfs_root->d_inode, &name, inode->i_ino, &info);
+					novfs_unlock_inode_cache(novfs_root->d_inode);
+				}
 			}
 		}
 	}
