diff options
author | Matthew Wilcox <mawilcox@microsoft.com> | 2018-06-07 10:57:18 -0400 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2018-06-12 19:19:22 -0400 |
commit | b2303d7bf76d36a5176c793df628d302be29ab82 (patch) | |
tree | 026b2c5394540f7e11042f2ecfa9ceed4ffa826a /drivers/vhost/vhost.c | |
parent | c817e6ccb2c36b8f564209d474bc6c8308c498e2 (diff) |
Convert vhost to struct_size
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'drivers/vhost/vhost.c')
-rw-r--r-- | drivers/vhost/vhost.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 895eaa25807c..f9bce818da11 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c | |||
@@ -1286,7 +1286,8 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m) | |||
1286 | return -EOPNOTSUPP; | 1286 | return -EOPNOTSUPP; |
1287 | if (mem.nregions > max_mem_regions) | 1287 | if (mem.nregions > max_mem_regions) |
1288 | return -E2BIG; | 1288 | return -E2BIG; |
1289 | newmem = kvzalloc(size + mem.nregions * sizeof(*m->regions), GFP_KERNEL); | 1289 | newmem = kvzalloc(struct_size(newmem, regions, mem.nregions), |
1290 | GFP_KERNEL); | ||
1290 | if (!newmem) | 1291 | if (!newmem) |
1291 | return -ENOMEM; | 1292 | return -ENOMEM; |
1292 | 1293 | ||