summaryrefslogtreecommitdiff
path: root/drivers/media/v4l2-core
diff options
context:
space:
mode:
authorPrashant Laddha <prladdha@cisco.com>2015-04-22 14:32:36 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-05-01 07:15:06 -0300
commit947ed99e5d1b1595312a320fb9db4f52965ceeae (patch)
tree0a33cd65467af1fb328b94824f897a02b1a7a9a1 /drivers/media/v4l2-core
parentd7ed5a3ddaec19d866ffc05ed2733179fbe4da9e (diff)
[media] v4l2-dv-timings: add sanity checks in cvt,gtf calculations
Wrong values of hfreq and image height can lead to strange timings. Avoid timing calculations for such values. Suggested By: Martin Bugge <marbugge@cisco.com> Cc: Martin Bugge <marbugge@cisco.com> Signed-off-by: Prashant Laddha <prladdha@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r--drivers/media/v4l2-core/v4l2-dv-timings.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
index 16c8ac5b5e0b..4e09792038ed 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -365,6 +365,9 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync,
else
return false;
+ if (hfreq == 0)
+ return false;
+
/* Vertical */
if (reduced_blanking) {
v_fp = CVT_RB_V_FPORCH;
@@ -382,6 +385,9 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync,
}
image_height = (frame_height - v_fp - vsync - v_bp + 1) & ~0x1;
+ if (image_height < 0)
+ return false;
+
/* Aspect ratio based on vsync */
switch (vsync) {
case 4:
@@ -527,12 +533,18 @@ bool v4l2_detect_gtf(unsigned frame_height,
else
return false;
+ if (hfreq == 0)
+ return false;
+
/* Vertical */
v_fp = GTF_V_FP;
v_bp = (GTF_MIN_VSYNC_BP * hfreq + 500000) / 1000000 - vsync;
image_height = (frame_height - v_fp - vsync - v_bp + 1) & ~0x1;
+ if (image_height < 0)
+ return false;
+
if (aspect.numerator == 0 || aspect.denominator == 0) {
aspect.numerator = 16;
aspect.denominator = 9;