Commit b00481bd authored by Dan Carpenter's avatar Dan Carpenter Committed by Mauro Carvalho Chehab

media: camss: Fix signedness bug in video_enum_fmt()

This test has a problem because we want to know if "k" is -1 or a
positive value less than "f->index".  But the "f->index" variable is a
u32 so if "k == -1" then -1 gets type promoted to UINT_MAX which is
larger than "f->index".  I've added an explicit test to check for -1.

Fixes: a3d412d4 ("media: Revert "media: camss: Make use of V4L2_CAP_IO_MC"")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarRobert Foss <robert.foss@linaro.org>
Reviewed-by: default avatarAndrey Konovalov <andrey.konovalov@linaro.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent a819678d
...@@ -579,7 +579,7 @@ static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f) ...@@ -579,7 +579,7 @@ static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
break; break;
} }
if (k < f->index) if (k == -1 || k < f->index)
/* /*
* All the unique pixel formats matching the arguments * All the unique pixel formats matching the arguments
* have been enumerated (k >= 0 and f->index > 0), or * have been enumerated (k >= 0 and f->index > 0), or
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment