Commit e4ce9ed835bc ("usb: gadget: uvc: ensure the vdev is unset")
introduced code to clear the video device on video device registration.
However, it uses sizeof(uvc->video) instead of sizeof(uvc->vdev) to clear
uvc->vdev. This may result in the following build error.
In function 'fortify_memset_chk',
inlined from 'uvc_register_video'
at drivers/usb/gadget/function/f_uvc.c:424:2:
include/linux/fortify-string.h:301:25: error:
call to '__write_overflow_field' declared with attribute warning:
detected write beyond size of field
The problem is exposed by commit 9b91a6523078 ("usb: gadget: uvc: increase
worker prio to WQ_HIGHPRI") which increases the size of struct uvc_video.
Fixes: e4ce9ed835bc ("usb: gadget: uvc: ensure the vdev is unset")
Cc: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx>
Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
---
drivers/usb/gadget/function/f_uvc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index e6948cf8def3..836601227155 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -421,7 +421,7 @@ uvc_register_video(struct uvc_device *uvc)
int ret;
/* TODO reference counting. */
- memset(&uvc->vdev, 0, sizeof(uvc->video));
+ memset(&uvc->vdev, 0, sizeof(uvc->vdev));
uvc->vdev.v4l2_dev = &uvc->v4l2_dev;
uvc->vdev.v4l2_dev->dev = &cdev->gadget->dev;
uvc->vdev.fops = &uvc_v4l2_fops;
--
2.36.2
Attachment:
signature.asc
Description: PGP signature