diff --git a/drivers/video/fbdev/msm/mdss_mdp_ctl.c b/drivers/video/fbdev/msm/mdss_mdp_ctl.c index 7b0207de101a..0ba5f6c8318e 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_ctl.c +++ b/drivers/video/fbdev/msm/mdss_mdp_ctl.c @@ -73,8 +73,18 @@ static void __mdss_mdp_mixer_write_cfg(struct mdss_mdp_mixer *mixer, static inline u64 fudge_factor(u64 val, u32 numer, u32 denom) { - u64 result = (val * (u64)numer); - do_div(result, denom); + u64 result = val; + + if (val) { + u64 temp = -1UL; + + do_div(temp, val); + if (temp > numer) { + /* no overflow, so we can do the operation*/ + result = (val * (u64)numer); + do_div(result, denom); + } + } return result; }