patch-1.3.25 linux/fs/smbfs/dir.c

Next file: linux/include/asm-alpha/pgtable.h
Previous file: linux/fs/proc/root.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.24/linux/fs/smbfs/dir.c linux/fs/smbfs/dir.c
@@ -180,12 +180,21 @@
 	{
 		i = sizeof (struct smb_dirent) * SMB_READDIR_CACHE_SIZE;
 		c_entry = (struct smb_dirent *) smb_kmalloc(i, GFP_KERNEL);
+		if (c_entry == NULL) {
+			printk("smb_readdir: no MEMORY for cache\n");
+			return -ENOMEM;
+		}
 		for (i = 0; i < SMB_READDIR_CACHE_SIZE; i++) {
 			c_entry[i].path =
                                 (char *) smb_kmalloc(SMB_MAXNAMELEN + 1,
                                                      GFP_KERNEL);
                         if (c_entry[i].path == NULL) {
                                 DPRINTK("smb_readdir: could not alloc path\n");
+				while (--i>=0)
+					kfree(c_entry[i].path);
+				kfree(c_entry);
+				c_entry = NULL;
+				return -ENOMEM;
                         }
                 }
 	}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this