From: Matthew Wilcox Date: Thu, 7 Jun 2018 14:57:15 +0000 (-0700) Subject: Convert virtio_console to struct_size X-Git-Tag: v4.19~793^2~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b572e25c3649235969e4ada67cde27b5bb24979;p=platform%2Fkernel%2Flinux-rpi.git Convert virtio_console to struct_size Signed-off-by: Matthew Wilcox Signed-off-by: Kees Cook --- diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 2108551..4bf7c06 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -433,8 +433,7 @@ static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size * Allocate buffer and the sg list. The sg list array is allocated * directly after the port_buffer struct. */ - buf = kmalloc(sizeof(*buf) + sizeof(struct scatterlist) * pages, - GFP_KERNEL); + buf = kmalloc(struct_size(buf, sg, pages), GFP_KERNEL); if (!buf) goto fail;