From: Guenter Roeck <linux@roeck-us.net>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Guenter Roeck <linux@roeck-us.net>,
Michael Grzeschik <m.grzeschik@pengutronix.de>
Subject: [PATCH] usb: gadget: uvc: Fix clearing of vdev
Date: Sun, 2 Oct 2022 10:44:30 -0700 [thread overview]
Message-ID: <20221002174430.3065870-1-linux@roeck-us.net> (raw)
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@pengutronix.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
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
next reply other threads:[~2022-10-02 17:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-02 17:44 Guenter Roeck [this message]
2022-10-02 18:05 ` [PATCH] usb: gadget: uvc: Fix clearing of vdev Michael Grzeschik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221002174430.3065870-1-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.grzeschik@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox