Commit b2303d7bf76d36a5176c793df628d302be29ab82

Authored by Matthew Wilcox
Committed by Kees Cook
1 parent c817e6ccb2

Convert vhost to struct_size

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Kees Cook <keescook@chromium.org>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

drivers/vhost/vhost.c
... ... @@ -1286,7 +1286,8 @@
1286 1286 return -EOPNOTSUPP;
1287 1287 if (mem.nregions > max_mem_regions)
1288 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 1291 if (!newmem)
1291 1292 return -ENOMEM;
1292 1293