Skip to content

Commit

Permalink
media: uvc: to the right check at uvc_ioctl_enum_framesizes()
Browse files Browse the repository at this point in the history
While the logic there is correct, it tricks both humans and
machines, a the check if "i" var is not zero is actually to
validate if the "frames" var was initialized when the loop
ran for the first time.

That produces the following warning:
	drivers/media/usb/uvc/uvc_v4l2.c:1192 uvc_ioctl_enum_framesizes() error: potentially dereferencing uninitialized 'frame'.

Change the logic to do the right test instead.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
  • Loading branch information
Mauro Carvalho Chehab committed Mar 23, 2018
1 parent 98c1ce0 commit 86b2989
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/media/usb/uvc/uvc_v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ static int uvc_ioctl_enum_framesizes(struct file *file, void *fh,
struct uvc_fh *handle = fh;
struct uvc_streaming *stream = handle->stream;
struct uvc_format *format = NULL;
struct uvc_frame *frame;
struct uvc_frame *frame = NULL;
unsigned int index;
unsigned int i;

Expand All @@ -1189,7 +1189,7 @@ static int uvc_ioctl_enum_framesizes(struct file *file, void *fh,

/* Skip duplicate frame sizes */
for (i = 0, index = 0; i < format->nframes; i++) {
if (i && frame->wWidth == format->frame[i].wWidth &&
if (frame && frame->wWidth == format->frame[i].wWidth &&
frame->wHeight == format->frame[i].wHeight)
continue;
frame = &format->frame[i];
Expand Down

0 comments on commit 86b2989

Please sign in to comment.