You need to sign in or sign up before continuing.
提交 86b29893 编写于 作者: M Mauro Carvalho Chehab

media: uvc: to the right check at uvc_ioctl_enum_framesizes()

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: NMauro Carvalho Chehab <mchehab@s-opensource.com>
上级 98c1ce0c
...@@ -1173,7 +1173,7 @@ static int uvc_ioctl_enum_framesizes(struct file *file, void *fh, ...@@ -1173,7 +1173,7 @@ static int uvc_ioctl_enum_framesizes(struct file *file, void *fh,
struct uvc_fh *handle = fh; struct uvc_fh *handle = fh;
struct uvc_streaming *stream = handle->stream; struct uvc_streaming *stream = handle->stream;
struct uvc_format *format = NULL; struct uvc_format *format = NULL;
struct uvc_frame *frame; struct uvc_frame *frame = NULL;
unsigned int index; unsigned int index;
unsigned int i; unsigned int i;
...@@ -1189,7 +1189,7 @@ static int uvc_ioctl_enum_framesizes(struct file *file, void *fh, ...@@ -1189,7 +1189,7 @@ static int uvc_ioctl_enum_framesizes(struct file *file, void *fh,
/* Skip duplicate frame sizes */ /* Skip duplicate frame sizes */
for (i = 0, index = 0; i < format->nframes; i++) { 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) frame->wHeight == format->frame[i].wHeight)
continue; continue;
frame = &format->frame[i]; frame = &format->frame[i];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册