@@ -639,11 +639,9 @@ ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes,
639639 int rc = 0 ;
640640
641641 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 )
645643 return - ENOMEM ;
646- }
644+
647645 (* packet_size ) = 0 ;
648646 rc = ecryptfs_find_auth_tok_for_sig (
649647 & auth_tok_key ,
@@ -687,7 +685,7 @@ ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes,
687685 * separator, and then the filename */
688686 s -> max_packet_size = (ECRYPTFS_TAG_70_MAX_METADATA_SIZE
689687 + s -> block_aligned_filename_size );
690- if (dest == NULL ) {
688+ if (! dest ) {
691689 (* packet_size ) = s -> max_packet_size ;
692690 goto out_unlock ;
693691 }
@@ -714,9 +712,6 @@ ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes,
714712 s -> block_aligned_filename = kzalloc (s -> block_aligned_filename_size ,
715713 GFP_KERNEL );
716714 if (!s -> block_aligned_filename ) {
717- printk (KERN_ERR "%s: Out of kernel memory whilst attempting to "
718- "kzalloc [%zd] bytes\n" , __func__ ,
719- s -> block_aligned_filename_size );
720715 rc = - ENOMEM ;
721716 goto out_unlock ;
722717 }
@@ -769,10 +764,6 @@ ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes,
769764 s -> hash_desc = kmalloc (sizeof (* s -> hash_desc ) +
770765 crypto_shash_descsize (s -> hash_tfm ), GFP_KERNEL );
771766 if (!s -> hash_desc ) {
772- printk (KERN_ERR "%s: Out of kernel memory whilst attempting to "
773- "kmalloc [%zd] bytes\n" , __func__ ,
774- sizeof (* s -> hash_desc ) +
775- crypto_shash_descsize (s -> hash_tfm ));
776767 rc = - ENOMEM ;
777768 goto out_release_free_unlock ;
778769 }
@@ -925,11 +916,9 @@ ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size,
925916 (* filename_size ) = 0 ;
926917 (* filename ) = NULL ;
927918 s = kzalloc (sizeof (* s ), GFP_KERNEL );
928- if (!s ) {
929- printk (KERN_ERR "%s: Out of memory whilst trying to kmalloc "
930- "[%zd] bytes of kernel memory\n" , __func__ , sizeof (* s ));
919+ if (!s )
931920 return - ENOMEM ;
932- }
921+
933922 if (max_packet_size < ECRYPTFS_TAG_70_MIN_METADATA_SIZE ) {
934923 printk (KERN_WARNING "%s: max_packet_size is [%zd]; it must be "
935924 "at least [%d]\n" , __func__ , max_packet_size ,
@@ -1015,9 +1004,6 @@ ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size,
10151004 s -> decrypted_filename = kmalloc (s -> block_aligned_filename_size ,
10161005 GFP_KERNEL );
10171006 if (!s -> decrypted_filename ) {
1018- printk (KERN_ERR "%s: Out of memory whilst attempting to "
1019- "kmalloc [%zd] bytes\n" , __func__ ,
1020- s -> block_aligned_filename_size );
10211007 rc = - ENOMEM ;
10221008 goto out_unlock ;
10231009 }
@@ -1097,9 +1083,6 @@ ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size,
10971083 }
10981084 (* filename ) = kmalloc (((* filename_size ) + 1 ), GFP_KERNEL );
10991085 if (!(* filename )) {
1100- printk (KERN_ERR "%s: Out of memory whilst attempting to "
1101- "kmalloc [%zd] bytes\n" , __func__ ,
1102- ((* filename_size ) + 1 ));
11031086 rc = - ENOMEM ;
11041087 goto out_free_unlock ;
11051088 }
@@ -1333,7 +1316,7 @@ parse_tag_1_packet(struct ecryptfs_crypt_stat *crypt_stat,
13331316 if ((* new_auth_tok )-> session_key .encrypted_key_size
13341317 > ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES ) {
13351318 printk (KERN_WARNING "Tag 1 packet contains key larger "
1336- "than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES" );
1319+ "than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES\n " );
13371320 rc = - EINVAL ;
13381321 goto out ;
13391322 }
@@ -2525,11 +2508,9 @@ int ecryptfs_add_keysig(struct ecryptfs_crypt_stat *crypt_stat, char *sig)
25252508 struct ecryptfs_key_sig * new_key_sig ;
25262509
25272510 new_key_sig = kmem_cache_alloc (ecryptfs_key_sig_cache , GFP_KERNEL );
2528- if (!new_key_sig ) {
2529- printk (KERN_ERR
2530- "Error allocating from ecryptfs_key_sig_cache\n" );
2511+ if (!new_key_sig )
25312512 return - ENOMEM ;
2532- }
2513+
25332514 memcpy (new_key_sig -> keysig , sig , ECRYPTFS_SIG_SIZE_HEX );
25342515 new_key_sig -> keysig [ECRYPTFS_SIG_SIZE_HEX ] = '\0' ;
25352516 /* Caller must hold keysig_list_mutex */
@@ -2545,24 +2526,19 @@ ecryptfs_add_global_auth_tok(struct ecryptfs_mount_crypt_stat *mount_crypt_stat,
25452526 char * sig , u32 global_auth_tok_flags )
25462527{
25472528 struct ecryptfs_global_auth_tok * new_auth_tok ;
2548- int rc = 0 ;
25492529
25502530 new_auth_tok = kmem_cache_zalloc (ecryptfs_global_auth_tok_cache ,
25512531 GFP_KERNEL );
2552- if (!new_auth_tok ) {
2553- rc = - ENOMEM ;
2554- printk (KERN_ERR "Error allocating from "
2555- "ecryptfs_global_auth_tok_cache\n" );
2556- goto out ;
2557- }
2532+ if (!new_auth_tok )
2533+ return - ENOMEM ;
2534+
25582535 memcpy (new_auth_tok -> sig , sig , ECRYPTFS_SIG_SIZE_HEX );
25592536 new_auth_tok -> flags = global_auth_tok_flags ;
25602537 new_auth_tok -> sig [ECRYPTFS_SIG_SIZE_HEX ] = '\0' ;
25612538 mutex_lock (& mount_crypt_stat -> global_auth_tok_list_mutex );
25622539 list_add (& new_auth_tok -> mount_crypt_stat_list ,
25632540 & mount_crypt_stat -> global_auth_tok_list );
25642541 mutex_unlock (& mount_crypt_stat -> global_auth_tok_list_mutex );
2565- out :
2566- return rc ;
2542+ return 0 ;
25672543}
25682544
0 commit comments