From: Gustavo A. R. Silva Date: Tue, 23 May 2023 01:35:59 +0000 (-0600) Subject: vfio/ccw: use struct_size() helper X-Git-Tag: v6.5-rc1~191^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d933e5f41e4f6c54f4bd3e0b29ca4854fe5fa0d6;p=thirdparty%2Fkernel%2Flinux.git 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 Reviewed-by: Kees Cook Reviewed-by: Eric Farman Reviewed-by: Matthew Rosato Link: https://lore.kernel.org/r/f657276073630e806e69726a40ad1cc85101448a.1684805398.git.gustavoars@kernel.org Signed-off-by: Alexander Gordeev --- diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c index 57906a9c63240..43601816ea4e4 100644 --- a/drivers/s390/cio/vfio_ccw_drv.c +++ b/drivers/s390/cio/vfio_ccw_drv.c @@ -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;