Commit d802ffa8850f2a80d141457d7221809182ed8c9f

Authored by Mingming Cao
Committed by Theodore Ts'o
1 parent 2d917969bc

JBD2/Ext4: Convert kmalloc to kzalloc in jbd2/ext4

Convert kmalloc to kzalloc() and get rid of the memset().

Signed-off-by: Mingming Cao <cmm@us.ibm.com>

Showing 3 changed files with 3 additions and 6 deletions Side-by-side Diff

... ... @@ -750,12 +750,11 @@
750 750 }
751 751 } else {
752 752 /* Allocate a buffer where we construct the new block. */
753   - s->base = kmalloc(sb->s_blocksize, GFP_KERNEL);
  753 + s->base = kzalloc(sb->s_blocksize, GFP_KERNEL);
754 754 /* assert(header == s->base) */
755 755 error = -ENOMEM;
756 756 if (s->base == NULL)
757 757 goto cleanup;
758   - memset(s->base, 0, sb->s_blocksize);
759 758 header(s->base)->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
760 759 header(s->base)->h_blocks = cpu_to_le32(1);
761 760 header(s->base)->h_refcount = cpu_to_le32(1);
... ... @@ -654,10 +654,9 @@
654 654 journal_t *journal;
655 655 int err;
656 656  
657   - journal = kmalloc(sizeof(*journal), GFP_KERNEL);
  657 + journal = kzalloc(sizeof(*journal), GFP_KERNEL|__GFP_NOFAIL);
658 658 if (!journal)
659 659 goto fail;
660   - memset(journal, 0, sizeof(*journal));
661 660  
662 661 init_waitqueue_head(&journal->j_wait_transaction_locked);
663 662 init_waitqueue_head(&journal->j_wait_logspace);
fs/jbd2/transaction.c
... ... @@ -96,13 +96,12 @@
96 96  
97 97 alloc_transaction:
98 98 if (!journal->j_running_transaction) {
99   - new_transaction = kmalloc(sizeof(*new_transaction),
  99 + new_transaction = kzalloc(sizeof(*new_transaction),
100 100 GFP_NOFS|__GFP_NOFAIL);
101 101 if (!new_transaction) {
102 102 ret = -ENOMEM;
103 103 goto out;
104 104 }
105   - memset(new_transaction, 0, sizeof(*new_transaction));
106 105 }
107 106  
108 107 jbd_debug(3, "New handle %p going live.\n", handle);