diff options
| author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2019-01-10 09:24:26 -0500 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-01-16 11:12:38 -0500 |
| commit | 7fe9f01c04c2673bd6662c35b664f0f91888b96f (patch) | |
| tree | f244e1df17f4af3b6c486e08294f696c14eae3a4 | |
| parent | 9048b2e15b11c591c649cc6edc7a64fa62c15419 (diff) | |
media: v4l: ioctl: Validate num_planes for debug messages
The num_planes field in struct v4l2_pix_format_mplane is used in a loop
before validating it. As the use is printing a debug message in this case,
just cap the value to the maximum allowed.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: stable@vger.kernel.org
Reviewed-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: <stable@vger.kernel.org> # for v4.12 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
| -rw-r--r-- | drivers/media/v4l2-core/v4l2-ioctl.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 44bc7c4f1c11..90aad465f9ed 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c | |||
| @@ -287,6 +287,7 @@ static void v4l_print_format(const void *arg, bool write_only) | |||
| 287 | const struct v4l2_window *win; | 287 | const struct v4l2_window *win; |
| 288 | const struct v4l2_sdr_format *sdr; | 288 | const struct v4l2_sdr_format *sdr; |
| 289 | const struct v4l2_meta_format *meta; | 289 | const struct v4l2_meta_format *meta; |
| 290 | u32 planes; | ||
| 290 | unsigned i; | 291 | unsigned i; |
| 291 | 292 | ||
| 292 | pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); | 293 | pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); |
| @@ -317,7 +318,8 @@ static void v4l_print_format(const void *arg, bool write_only) | |||
| 317 | prt_names(mp->field, v4l2_field_names), | 318 | prt_names(mp->field, v4l2_field_names), |
| 318 | mp->colorspace, mp->num_planes, mp->flags, | 319 | mp->colorspace, mp->num_planes, mp->flags, |
| 319 | mp->ycbcr_enc, mp->quantization, mp->xfer_func); | 320 | mp->ycbcr_enc, mp->quantization, mp->xfer_func); |
| 320 | for (i = 0; i < mp->num_planes; i++) | 321 | planes = min_t(u32, mp->num_planes, VIDEO_MAX_PLANES); |
| 322 | for (i = 0; i < planes; i++) | ||
| 321 | printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i, | 323 | printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i, |
| 322 | mp->plane_fmt[i].bytesperline, | 324 | mp->plane_fmt[i].bytesperline, |
| 323 | mp->plane_fmt[i].sizeimage); | 325 | mp->plane_fmt[i].sizeimage); |
