summaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab2018-03-23 13:23:23 +0100
committerMauro Carvalho Chehab2018-03-23 13:37:27 +0100
commit86b2989361df6fd9bb3f46518b5326775c76358d (patch)
treee9c09f4288f59bf15edaea63aad46252d306c4f6 /drivers/media
parentmedia: cec-core: fix a bug at cec_error_inj_write() (diff)
downloadkernel-qcow2-linux-86b2989361df6fd9bb3f46518b5326775c76358d.tar.gz
kernel-qcow2-linux-86b2989361df6fd9bb3f46518b5326775c76358d.tar.xz
kernel-qcow2-linux-86b2989361df6fd9bb3f46518b5326775c76358d.zip
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: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/uvc/uvc_v4l2.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 818a4369a51a..bd32914259ae 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -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;
@@ -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];