Convert v4l2 event to struct_size
authorMatthew Wilcox <mawilcox@microsoft.com>
Thu, 7 Jun 2018 14:57:17 +0000 (07:57 -0700)
committerKees Cook <keescook@chromium.org>
Tue, 12 Jun 2018 23:19:22 +0000 (16:19 -0700)
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
drivers/media/v4l2-core/v4l2-event.c

index 968c2eb..127fe6e 100644 (file)
@@ -215,8 +215,7 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
        if (elems < 1)
                elems = 1;
 
-       sev = kvzalloc(sizeof(*sev) + sizeof(struct v4l2_kevent) * elems,
-                      GFP_KERNEL);
+       sev = kvzalloc(struct_size(sev, events, elems), GFP_KERNEL);
        if (!sev)
                return -ENOMEM;
        for (i = 0; i < elems; i++)