mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-05 19:31:57 -04:00
media: v4l2-dv-timings: prevent possible overflow in v4l2_detect_gtf()
commit 3edd1fc48d2c045e8259561797c89fe78f01717e upstream.
In v4l2_detect_gtf(), it seems safer to cast the 32-bit image_width
variable to the 64-bit type u64 before multiplying to avoid
a possible overflow. The resulting object code even seems to
look better, at least on x86_64.
Found by Linux Verification Center (linuxtesting.org) with Svace.
[Sergey: rewrote the patch subject/descripition]
Fixes: c9bc9f5075 ("[media] v4l2-dv-timings: fix overflow in gtf timings calculation")
Cc: stable@vger.kernel.org
Signed-off-by: Karina Yankevich <k.yankevich@omp.ru>
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
30b46f95f8
commit
00b363790b
1 changed files with 2 additions and 2 deletions
|
|
@ -755,7 +755,7 @@ bool v4l2_detect_gtf(unsigned frame_height,
|
|||
u64 num;
|
||||
u32 den;
|
||||
|
||||
num = ((image_width * GTF_D_C_PRIME * (u64)hfreq) -
|
||||
num = (((u64)image_width * GTF_D_C_PRIME * hfreq) -
|
||||
((u64)image_width * GTF_D_M_PRIME * 1000));
|
||||
den = (hfreq * (100 - GTF_D_C_PRIME) + GTF_D_M_PRIME * 1000) *
|
||||
(2 * GTF_CELL_GRAN);
|
||||
|
|
@ -765,7 +765,7 @@ bool v4l2_detect_gtf(unsigned frame_height,
|
|||
u64 num;
|
||||
u32 den;
|
||||
|
||||
num = ((image_width * GTF_S_C_PRIME * (u64)hfreq) -
|
||||
num = (((u64)image_width * GTF_S_C_PRIME * hfreq) -
|
||||
((u64)image_width * GTF_S_M_PRIME * 1000));
|
||||
den = (hfreq * (100 - GTF_S_C_PRIME) + GTF_S_M_PRIME * 1000) *
|
||||
(2 * GTF_CELL_GRAN);
|
||||
|
|
|
|||
Loading…
Reference in a new issue