summaryrefslogtreecommitdiff
path: root/drivers/md/dm-crypt.c
diff options
context:
space:
mode:
authorZhengyuan Liu <liuzhengyuan@kylinos.cn>2019-06-12 09:14:45 +0300
committerMike Snitzer <snitzer@redhat.com>2019-07-09 21:08:40 +0300
commit9c81c99b242f1241e18573d1ce29f7479c168e38 (patch)
treed1101ca89132efca5d6d64e10389c602e2f36483 /drivers/md/dm-crypt.c
parent5f1c56b34e81e2d63f345f7ad6c5c7971c3c314d (diff)
downloadlinux-9c81c99b242f1241e18573d1ce29f7479c168e38.tar.xz
dm crypt: use struct_size() when allocating encryption context
Use struct_size() to avoid open-coded equivalent that is prone to a type mistake. Signed-off-by: Zhengyuan Liu <liuzhengyuan@kylinos.cn> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-crypt.c')
-rw-r--r--drivers/md/dm-crypt.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 1b16d34bb785..2587e94b0511 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2699,7 +2699,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
return -EINVAL;
}
- cc = kzalloc(sizeof(*cc) + key_size * sizeof(u8), GFP_KERNEL);
+ cc = kzalloc(struct_size(cc, key, key_size), GFP_KERNEL);
if (!cc) {
ti->error = "Cannot allocate encryption context";
return -ENOMEM;