Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ecryptfs: Delete 21 error messages for a failed memory allocation

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>

authored by

Markus Elfring and committed by
Tyler Hicks
1a0bba4f db86be3a

+7 -59
-16
fs/ecryptfs/crypto.c
··· 1419 1419 page_virt = kmem_cache_alloc(ecryptfs_header_cache, GFP_USER); 1420 1420 if (!page_virt) { 1421 1421 rc = -ENOMEM; 1422 - printk(KERN_ERR "%s: Unable to allocate page_virt\n", 1423 - __func__); 1424 1422 goto out; 1425 1423 } 1426 1424 rc = ecryptfs_read_lower(page_virt, 0, crypt_stat->extent_size, ··· 1505 1507 filename->encrypted_filename = 1506 1508 kmalloc(filename->encrypted_filename_size, GFP_KERNEL); 1507 1509 if (!filename->encrypted_filename) { 1508 - printk(KERN_ERR "%s: Out of memory whilst attempting " 1509 - "to kmalloc [%zd] bytes\n", __func__, 1510 - filename->encrypted_filename_size); 1511 1510 rc = -ENOMEM; 1512 1511 goto out; 1513 1512 } ··· 1653 1658 (*key_tfm) = tmp_tfm; 1654 1659 if (!tmp_tfm) { 1655 1660 rc = -ENOMEM; 1656 - printk(KERN_ERR "Error attempting to allocate from " 1657 - "ecryptfs_key_tfm_cache\n"); 1658 1661 goto out; 1659 1662 } 1660 1663 mutex_init(&tmp_tfm->key_tfm_mutex); ··· 1927 1934 1928 1935 filename = kzalloc(sizeof(*filename), GFP_KERNEL); 1929 1936 if (!filename) { 1930 - printk(KERN_ERR "%s: Out of memory whilst attempting " 1931 - "to kzalloc [%zd] bytes\n", __func__, 1932 - sizeof(*filename)); 1933 1937 rc = -ENOMEM; 1934 1938 goto out; 1935 1939 } ··· 1955 1965 + encoded_name_no_prefix_size); 1956 1966 (*encoded_name) = kmalloc((*encoded_name_size) + 1, GFP_KERNEL); 1957 1967 if (!(*encoded_name)) { 1958 - printk(KERN_ERR "%s: Out of memory whilst attempting " 1959 - "to kzalloc [%zd] bytes\n", __func__, 1960 - (*encoded_name_size)); 1961 1968 rc = -ENOMEM; 1962 1969 kfree(filename->encrypted_filename); 1963 1970 kfree(filename); ··· 2036 2049 name, name_size); 2037 2050 decoded_name = kmalloc(decoded_name_size, GFP_KERNEL); 2038 2051 if (!decoded_name) { 2039 - printk(KERN_ERR "%s: Out of memory whilst attempting " 2040 - "to kmalloc [%zd] bytes\n", __func__, 2041 - decoded_name_size); 2042 2052 rc = -ENOMEM; 2043 2053 goto out; 2044 2054 }
-3
fs/ecryptfs/inode.c
··· 334 334 335 335 dentry_info = kmem_cache_alloc(ecryptfs_dentry_info_cache, GFP_KERNEL); 336 336 if (!dentry_info) { 337 - printk(KERN_ERR "%s: Out of memory whilst attempting " 338 - "to allocate ecryptfs_dentry_info struct\n", 339 - __func__); 340 337 dput(lower_dentry); 341 338 return ERR_PTR(-ENOMEM); 342 339 }
+6 -27
fs/ecryptfs/keystore.c
··· 639 639 int rc = 0; 640 640 641 641 s = kzalloc(sizeof(*s), GFP_KERNEL); 642 - if (!s) { 643 - printk(KERN_ERR "%s: Out of memory whilst trying to kmalloc " 644 - "[%zd] bytes of kernel memory\n", __func__, sizeof(*s)); 642 + if (!s) 645 643 return -ENOMEM; 646 - } 644 + 647 645 (*packet_size) = 0; 648 646 rc = ecryptfs_find_auth_tok_for_sig( 649 647 &auth_tok_key, ··· 712 714 s->block_aligned_filename = kzalloc(s->block_aligned_filename_size, 713 715 GFP_KERNEL); 714 716 if (!s->block_aligned_filename) { 715 - printk(KERN_ERR "%s: Out of kernel memory whilst attempting to " 716 - "kzalloc [%zd] bytes\n", __func__, 717 - s->block_aligned_filename_size); 718 717 rc = -ENOMEM; 719 718 goto out_unlock; 720 719 } ··· 764 769 s->hash_desc = kmalloc(sizeof(*s->hash_desc) + 765 770 crypto_shash_descsize(s->hash_tfm), GFP_KERNEL); 766 771 if (!s->hash_desc) { 767 - printk(KERN_ERR "%s: Out of kernel memory whilst attempting to " 768 - "kmalloc [%zd] bytes\n", __func__, 769 - sizeof(*s->hash_desc) + 770 - crypto_shash_descsize(s->hash_tfm)); 771 772 rc = -ENOMEM; 772 773 goto out_release_free_unlock; 773 774 } ··· 916 925 (*filename_size) = 0; 917 926 (*filename) = NULL; 918 927 s = kzalloc(sizeof(*s), GFP_KERNEL); 919 - if (!s) { 920 - printk(KERN_ERR "%s: Out of memory whilst trying to kmalloc " 921 - "[%zd] bytes of kernel memory\n", __func__, sizeof(*s)); 928 + if (!s) 922 929 return -ENOMEM; 923 - } 930 + 924 931 if (max_packet_size < ECRYPTFS_TAG_70_MIN_METADATA_SIZE) { 925 932 printk(KERN_WARNING "%s: max_packet_size is [%zd]; it must be " 926 933 "at least [%d]\n", __func__, max_packet_size, ··· 1004 1015 s->decrypted_filename = kmalloc(s->block_aligned_filename_size, 1005 1016 GFP_KERNEL); 1006 1017 if (!s->decrypted_filename) { 1007 - printk(KERN_ERR "%s: Out of memory whilst attempting to " 1008 - "kmalloc [%zd] bytes\n", __func__, 1009 - s->block_aligned_filename_size); 1010 1018 rc = -ENOMEM; 1011 1019 goto out_unlock; 1012 1020 } ··· 1083 1097 } 1084 1098 (*filename) = kmalloc(((*filename_size) + 1), GFP_KERNEL); 1085 1099 if (!(*filename)) { 1086 - printk(KERN_ERR "%s: Out of memory whilst attempting to " 1087 - "kmalloc [%zd] bytes\n", __func__, 1088 - ((*filename_size) + 1)); 1089 1100 rc = -ENOMEM; 1090 1101 goto out_free_unlock; 1091 1102 } ··· 2508 2525 struct ecryptfs_key_sig *new_key_sig; 2509 2526 2510 2527 new_key_sig = kmem_cache_alloc(ecryptfs_key_sig_cache, GFP_KERNEL); 2511 - if (!new_key_sig) { 2512 - printk(KERN_ERR 2513 - "Error allocating from ecryptfs_key_sig_cache\n"); 2528 + if (!new_key_sig) 2514 2529 return -ENOMEM; 2515 - } 2530 + 2516 2531 memcpy(new_key_sig->keysig, sig, ECRYPTFS_SIG_SIZE_HEX); 2517 2532 new_key_sig->keysig[ECRYPTFS_SIG_SIZE_HEX] = '\0'; 2518 2533 /* Caller must hold keysig_list_mutex */ ··· 2532 2551 GFP_KERNEL); 2533 2552 if (!new_auth_tok) { 2534 2553 rc = -ENOMEM; 2535 - printk(KERN_ERR "Error allocating from " 2536 - "ecryptfs_global_auth_tok_cache\n"); 2537 2554 goto out; 2538 2555 } 2539 2556 memcpy(new_auth_tok->sig, sig, ECRYPTFS_SIG_SIZE_HEX);
-6
fs/ecryptfs/messaging.c
··· 147 147 (*daemon) = kzalloc(sizeof(**daemon), GFP_KERNEL); 148 148 if (!(*daemon)) { 149 149 rc = -ENOMEM; 150 - printk(KERN_ERR "%s: Failed to allocate [%zd] bytes of " 151 - "GFP_KERNEL memory\n", __func__, sizeof(**daemon)); 152 150 goto out; 153 151 } 154 152 (*daemon)->file = file; ··· 248 250 msg_ctx->msg = kmemdup(msg, msg_size, GFP_KERNEL); 249 251 if (!msg_ctx->msg) { 250 252 rc = -ENOMEM; 251 - printk(KERN_ERR "%s: Failed to allocate [%zd] bytes of " 252 - "GFP_KERNEL memory\n", __func__, msg_size); 253 253 goto unlock; 254 254 } 255 255 msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_DONE; ··· 382 386 GFP_KERNEL); 383 387 if (!ecryptfs_daemon_hash) { 384 388 rc = -ENOMEM; 385 - printk(KERN_ERR "%s: Failed to allocate memory\n", __func__); 386 389 mutex_unlock(&ecryptfs_daemon_hash_mux); 387 390 goto out; 388 391 } ··· 393 398 GFP_KERNEL); 394 399 if (!ecryptfs_msg_ctx_arr) { 395 400 rc = -ENOMEM; 396 - printk(KERN_ERR "%s: Failed to allocate memory\n", __func__); 397 401 goto out; 398 402 } 399 403 mutex_init(&ecryptfs_msg_ctx_lists_mux);
+1 -5
fs/ecryptfs/miscdev.c
··· 163 163 struct ecryptfs_message *msg; 164 164 165 165 msg = kmalloc((sizeof(*msg) + data_size), GFP_KERNEL); 166 - if (!msg) { 167 - printk(KERN_ERR "%s: Out of memory whilst attempting " 168 - "to kmalloc(%zd, GFP_KERNEL)\n", __func__, 169 - (sizeof(*msg) + data_size)); 166 + if (!msg) 170 167 return -ENOMEM; 171 - } 172 168 173 169 mutex_lock(&msg_ctx->mux); 174 170 msg_ctx->msg = msg;
-2
fs/ecryptfs/mmap.c
··· 431 431 } 432 432 xattr_virt = kmem_cache_alloc(ecryptfs_xattr_cache, GFP_KERNEL); 433 433 if (!xattr_virt) { 434 - printk(KERN_ERR "Out of memory whilst attempting to write " 435 - "inode size to xattr\n"); 436 434 rc = -ENOMEM; 437 435 goto out; 438 436 }