Skip to content

Commit

Permalink
Convert vhost to struct_size
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
  • Loading branch information
Matthew Wilcox authored and Kees Cook committed Jun 12, 2018
1 parent c817e6c commit b2303d7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/vhost/vhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,8 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
return -EOPNOTSUPP;
if (mem.nregions > max_mem_regions)
return -E2BIG;
newmem = kvzalloc(size + mem.nregions * sizeof(*m->regions), GFP_KERNEL);
newmem = kvzalloc(struct_size(newmem, regions, mem.nregions),
GFP_KERNEL);
if (!newmem)
return -ENOMEM;

Expand Down

0 comments on commit b2303d7

Please sign in to comment.