dm integrity: use kzalloc() instead of kmalloc() + memset()
authorFuqian Huang <huangfq.daxian@gmail.com>
Fri, 28 Jun 2019 02:47:34 +0000 (10:47 +0800)
committerMike Snitzer <snitzer@redhat.com>
Tue, 9 Jul 2019 18:14:20 +0000 (14:14 -0400)
Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-integrity.c

index a2ab6a32b1740253c2a938f0201bdbb839d87a07..b1b0de402dfc36eb937cc1967dcf4a341057b576 100644 (file)
@@ -3360,7 +3360,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
                                goto bad;
                        }
 
-                       crypt_iv = kmalloc(ivsize, GFP_KERNEL);
+                       crypt_iv = kzalloc(ivsize, GFP_KERNEL);
                        if (!crypt_iv) {
                                *error = "Could not allocate iv";
                                r = -ENOMEM;
@@ -3389,7 +3389,6 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
                                sg_set_buf(&sg[i], va, PAGE_SIZE);
                        }
                        sg_set_buf(&sg[i], &ic->commit_ids, sizeof ic->commit_ids);
-                       memset(crypt_iv, 0x00, ivsize);
 
                        skcipher_request_set_crypt(req, sg, sg,
                                                   PAGE_SIZE * ic->journal_pages + sizeof ic->commit_ids, crypt_iv);