Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-drm-fsl-dcu.git] / fs / ecryptfs / crypto.c
index f49f105394b70a91268a7ed63d56544aeff10fba..75bbfae5508124d024215937bedd877b27b3ee28 100644 (file)
@@ -134,7 +134,7 @@ int ecryptfs_crypto_api_algify_cipher_name(char **algified_name,
 
        algified_name_len = (chaining_modifier_len + cipher_name_len + 3);
        (*algified_name) = kmalloc(algified_name_len, GFP_KERNEL);
-       if (!(algified_name)) {
+       if (!(*algified_name)) {
                rc = -ENOMEM;
                goto out;
        }
@@ -628,7 +628,7 @@ int ecryptfs_decrypt_page(struct file *file, struct page *page)
        num_extents_per_page = PAGE_CACHE_SIZE / crypt_stat->extent_size;
        base_extent = (page->index * num_extents_per_page);
        lower_page_virt = kmem_cache_alloc(ecryptfs_lower_page_cache,
-                                          SLAB_KERNEL);
+                                          GFP_KERNEL);
        if (!lower_page_virt) {
                rc = -ENOMEM;
                ecryptfs_printk(KERN_ERR, "Error getting page for encrypted "
@@ -820,16 +820,15 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
        crypt_stat->tfm = crypto_alloc_blkcipher(full_alg_name, 0,
                                                 CRYPTO_ALG_ASYNC);
        kfree(full_alg_name);
-       if (!crypt_stat->tfm) {
+       if (IS_ERR(crypt_stat->tfm)) {
+               rc = PTR_ERR(crypt_stat->tfm);
                ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): "
                                "Error initializing cipher [%s]\n",
                                crypt_stat->cipher);
                mutex_unlock(&crypt_stat->cs_tfm_mutex);
                goto out;
        }
-       crypto_blkcipher_set_flags(crypt_stat->tfm,
-                                  (ECRYPTFS_DEFAULT_CHAINING_MODE
-                                   | CRYPTO_TFM_REQ_WEAK_KEY));
+       crypto_blkcipher_set_flags(crypt_stat->tfm, CRYPTO_TFM_REQ_WEAK_KEY);
        mutex_unlock(&crypt_stat->cs_tfm_mutex);
        rc = 0;
 out:
@@ -1333,13 +1332,13 @@ int ecryptfs_write_headers(struct dentry *ecryptfs_dentry,
                goto out;
        }
        /* Released in this function */
-       page_virt = kmem_cache_alloc(ecryptfs_header_cache_0, SLAB_USER);
+       page_virt = kmem_cache_zalloc(ecryptfs_header_cache_0, GFP_USER);
        if (!page_virt) {
                ecryptfs_printk(KERN_ERR, "Out of memory\n");
                rc = -ENOMEM;
                goto out;
        }
-       memset(page_virt, 0, PAGE_CACHE_SIZE);
+
        rc = ecryptfs_write_headers_virt(page_virt, crypt_stat,
                                         ecryptfs_dentry);
        if (unlikely(rc)) {
@@ -1492,7 +1491,7 @@ int ecryptfs_read_headers(struct dentry *ecryptfs_dentry,
            &ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->crypt_stat;
 
        /* Read the first page from the underlying file */
-       page_virt = kmem_cache_alloc(ecryptfs_header_cache_1, SLAB_USER);
+       page_virt = kmem_cache_alloc(ecryptfs_header_cache_1, GFP_USER);
        if (!page_virt) {
                rc = -ENOMEM;
                ecryptfs_printk(KERN_ERR, "Unable to allocate page_virt\n");