vfio/ccw: use struct_size() helper

Prefer struct_size() over open-coded versions.

Link: https://github.com/KSPP/linux/issues/160
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Link: https://lore.kernel.org/r/f657276073630e806e69726a40ad1cc85101448a.1684805398.git.gustavoars@kernel.org
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
This commit is contained in:
Gustavo A. R. Silva 2023-05-22 19:35:59 -06:00 committed by Alexander Gordeev
parent 5dd4241964
commit d933e5f41e
1 changed files with 1 additions and 2 deletions

View File

@ -171,8 +171,7 @@ static int vfio_ccw_sch_probe(struct subchannel *sch)
return -ENODEV;
}
parent = kzalloc(sizeof(*parent) + sizeof(struct mdev_type *),
GFP_KERNEL);
parent = kzalloc(struct_size(parent, mdev_types, 1), GFP_KERNEL);
if (!parent)
return -ENOMEM;