@@ -152,7 +152,7 @@ struct asymmetric_key_id *asymmetric_key_generate_id(const void *val_1,
{
struct asymmetric_key_id *kid;
- kid = kmalloc(sizeof(struct asymmetric_key_id) + len_1 + len_2,
+ kid = kmalloc(struct_size(kid, data, size_add(len_1, len_2)),
GFP_KERNEL);
if (!kid)
return ERR_PTR(-ENOMEM);
@@ -244,7 +244,7 @@ struct asymmetric_key_id *asymmetric_key_hex_to_key_id(const char *id)
if (asciihexlen & 1)
return ERR_PTR(-EINVAL);
- match_id = kmalloc(sizeof(struct asymmetric_key_id) + asciihexlen / 2,
+ match_id = kmalloc(struct_size(match_id, data, asciihexlen / 2),
GFP_KERNEL);
if (!match_id)
return ERR_PTR(-ENOMEM);