Message ID | 20230420100958.10631-5-laurent.pinchart@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series | media: uvcvideo: Misc cleanups | expand |
On Thu, 20 Apr 2023 at 12:10, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > > There is no need to modify the content of UVC descriptor buffers during > parsing. Make all the corresponding pointers const to avoid unintended > modifications. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/usb/uvc/uvc_driver.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > index efc7a36a892e..ab7f2a0112d3 100644 > --- a/drivers/media/usb/uvc/uvc_driver.c > +++ b/drivers/media/usb/uvc/uvc_driver.c > @@ -221,7 +221,7 @@ static struct uvc_streaming *uvc_stream_new(struct uvc_device *dev, > > static int uvc_parse_format(struct uvc_device *dev, > struct uvc_streaming *streaming, struct uvc_format *format, > - struct uvc_frame *frames, u32 **intervals, unsigned char *buffer, > + struct uvc_frame *frames, u32 **intervals, const unsigned char *buffer, > int buflen) > { > struct usb_interface *intf = streaming->intf; > @@ -494,7 +494,7 @@ static int uvc_parse_streaming(struct uvc_device *dev, > struct uvc_format *format; > struct uvc_frame *frame; > struct usb_host_interface *alts = &intf->altsetting[0]; > - unsigned char *_buffer, *buffer = alts->extra; > + const unsigned char *_buffer, *buffer = alts->extra; > int _buflen, buflen = alts->extralen; > unsigned int nformats = 0, nframes = 0, nintervals = 0; > unsigned int size, i, n, p; > @@ -1146,7 +1146,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev, > static int uvc_parse_control(struct uvc_device *dev) > { > struct usb_host_interface *alts = dev->intf->cur_altsetting; > - unsigned char *buffer = alts->extra; > + const unsigned char *buffer = alts->extra; > int buflen = alts->extralen; > int ret; > > -- > Regards, > > Laurent Pinchart >
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index efc7a36a892e..ab7f2a0112d3 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -221,7 +221,7 @@ static struct uvc_streaming *uvc_stream_new(struct uvc_device *dev, static int uvc_parse_format(struct uvc_device *dev, struct uvc_streaming *streaming, struct uvc_format *format, - struct uvc_frame *frames, u32 **intervals, unsigned char *buffer, + struct uvc_frame *frames, u32 **intervals, const unsigned char *buffer, int buflen) { struct usb_interface *intf = streaming->intf; @@ -494,7 +494,7 @@ static int uvc_parse_streaming(struct uvc_device *dev, struct uvc_format *format; struct uvc_frame *frame; struct usb_host_interface *alts = &intf->altsetting[0]; - unsigned char *_buffer, *buffer = alts->extra; + const unsigned char *_buffer, *buffer = alts->extra; int _buflen, buflen = alts->extralen; unsigned int nformats = 0, nframes = 0, nintervals = 0; unsigned int size, i, n, p; @@ -1146,7 +1146,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev, static int uvc_parse_control(struct uvc_device *dev) { struct usb_host_interface *alts = dev->intf->cur_altsetting; - unsigned char *buffer = alts->extra; + const unsigned char *buffer = alts->extra; int buflen = alts->extralen; int ret;
There is no need to modify the content of UVC descriptor buffers during parsing. Make all the corresponding pointers const to avoid unintended modifications. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- drivers/media/usb/uvc/uvc_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)