vfio/ccw: use struct_size() helper
authorGustavo A. R. Silva <gustavoars@kernel.org>
Tue, 23 May 2023 01:35:59 +0000 (19:35 -0600)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Thu, 1 Jun 2023 15:07:56 +0000 (17:07 +0200)
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>
drivers/s390/cio/vfio_ccw_drv.c

index 57906a9..4360181 100644 (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;