Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Convert vhost to struct_size

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

authored by

Matthew Wilcox and committed by
Kees Cook
b2303d7b c817e6cc

+2 -1
+2 -1
drivers/vhost/vhost.c
··· 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