Skip to contentSkip to conversation

fs/cifs/readdir.c: check kmalloc() return value.

PATCH New Amit Choudhary 1 participant 1 message Mar 9, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/cifs/readdir.c: check kmalloc() return value.

Description: Check the return value of kmalloc() in function cifs_readdir(), in file fs/cifs/readdir.c.

fs/cifs/readdir.c +5 -0
index b5b0a2a..2d43b2a 100644
@@ -1063,6 +1063,11 @@ int cifs_readdir(struct file *file, void
 		such multibyte target UTF-8 characters. cifs_unicode.c,
 		which actually does the conversion, has the same limit */
 		tmp_buf = kmalloc((2 * NAME_MAX) + 4, GFP_KERNEL);
+		if (!tmp_buf) {
+			cERROR(1, ("No memory!"));
+			rc = -ENOMEM;
+			goto rddir2_exit;
+		}
 		for(i=0;(i<num_to_fill) && (rc == 0);i++) {
 			if(current_entry == NULL) {
 				/* evaluate whether this case is an error */