lkml.org 
[lkml]   [2023]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] media: uvcvideo: Silence memcpy() run-time false positive warnings
On Mon, Jan 09, 2023 at 11:46:00AM +0100, Ricardo Ribalda wrote:
> Hi Laurent
>
> I was thinking about something on the line of the attached patch,
>
> uvc_frame_header->data could also be replaced with a union.
>
> Warning, not tested ;)

...

> +struct uvc_frame_header {
> + u8 length;
> + u8 flags;
> + u8 data[];
> +} __packed;

__packed! (See below)

...

> + pts = (u32 *) header->data;

Ai-ai-ai.
Here is just a yellow flag...

...

> uvc_dbg(stream->dev, FRAME,
> "%s(): t-sys %lluns, SOF %u, len %u, flags 0x%x, PTS %u, STC %u frame SOF %u\n",
> __func__, ktime_to_ns(time), meta->sof, meta->length,
> meta->flags,
> + has_pts ? *pts : 0,

...and here is a red flag. What you need to have is

void *pts;
u32 pts_val;

pts_val = get_unaligned_be32(); // or le32

...use pts_val...

> + has_scr ? scr->scr : 0,
> + has_scr ? scr->frame_sof & 0x7ff : 0);


--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2023-03-27 00:14    [W:0.407 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site