fs: cifs: check kmalloc() result
authorKulikov Vasiliy <segooon@gmail.com>
Fri, 16 Jul 2010 16:15:25 +0000 (20:15 +0400)
committerSteve French <sfrench@us.ibm.com>
Mon, 2 Aug 2010 12:40:39 +0000 (12:40 +0000)
If kmalloc() fails exit with -ENOMEM.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Acked-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/readdir.c

index daf1753af674584e2f83f5c1c974da7762097801..d5e591fab4753bf48bde4e9d7883f1051d2dc280 100644 (file)
@@ -847,6 +847,11 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
                end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len;
 
                tmp_buf = kmalloc(UNICODE_NAME_MAX, GFP_KERNEL);
+               if (tmp_buf == NULL) {
+                       rc = -ENOMEM;
+                       break;
+               }
+
                for (i = 0; (i < num_to_fill) && (rc == 0); i++) {
                        if (current_entry == NULL) {
                                /* evaluate whether this case is an error */