summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2018-06-07 07:57:15 -0700
committerKees Cook <keescook@chromium.org>2018-06-12 16:19:22 -0700
commit5b572e25c3649235969e4ada67cde27b5bb24979 (patch)
tree404a3135e0eb76e9c0657e6cabaa000b3781d985 /drivers/char
parent8958fd411ba08aa3ac1aeb19828abaf9cf33f7b8 (diff)
downloadlinux-5b572e25c3649235969e4ada67cde27b5bb24979.tar.bz2
Convert virtio_console to struct_size
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/virtio_console.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 21085515814f..4bf7c06c2343 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;