1 From 89dd34caf73e28018c58cd193751e41b1f8bdc56 Mon Sep 17 00:00:00 2001
2 From: Nadav Amit <namit@vmware.com>
3 Date: Mon, 4 Jun 2018 09:47:13 -0400
4 Subject: media: uvcvideo: Fix uvc_alloc_entity() allocation alignment
6 From: Nadav Amit <namit@vmware.com>
8 commit 89dd34caf73e28018c58cd193751e41b1f8bdc56 upstream.
10 The use of ALIGN() in uvc_alloc_entity() is incorrect, since the size of
11 (entity->pads) is not a power of two. As a stop-gap, until a better
12 solution is adapted, use roundup() instead.
14 Found by a static assertion. Compile-tested only.
16 Fixes: 4ffc2d89f38a ("uvcvideo: Register subdevices for each entity")
18 Signed-off-by: Nadav Amit <namit@vmware.com>
19 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
20 Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
21 Cc: Doug Anderson <dianders@chromium.org>
22 Cc: Ben Hutchings <ben@decadent.org.uk>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26 drivers/media/usb/uvc/uvc_driver.c | 2 +-
27 1 file changed, 1 insertion(+), 1 deletion(-)
29 --- a/drivers/media/usb/uvc/uvc_driver.c
30 +++ b/drivers/media/usb/uvc/uvc_driver.c
31 @@ -868,7 +868,7 @@ static struct uvc_entity *uvc_alloc_enti
35 - extra_size = ALIGN(extra_size, sizeof(*entity->pads));
36 + extra_size = roundup(extra_size, sizeof(*entity->pads));
37 num_inputs = (type & UVC_TERM_OUTPUT) ? num_pads : num_pads - 1;
38 size = sizeof(*entity) + extra_size + sizeof(*entity->pads) * num_pads