Commit 9c81c99b authored by Zhengyuan Liu's avatar Zhengyuan Liu Committed by Mike Snitzer

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: default avatarZhengyuan Liu <liuzhengyuan@kylinos.cn>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 5f1c56b3
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment