[media] omap3isp: Fix division by 0
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Thu, 25 Sep 2014 12:22:00 +0000 (09:22 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 23 Dec 2014 10:43:54 +0000 (08:43 -0200)
If the requested clock rate passed to the XCLK set_rate or round_rate
operation is 0, the driver will try to divide by 0. Fix this.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/omap3isp/isp.c

index 51c2129bdcc64e45e1467c2c2f0f533ebe70f113..deca80903c3a08fd59e875b110d4cb0fa3b5189f 100644 (file)
@@ -220,6 +220,9 @@ static u32 isp_xclk_calc_divider(unsigned long *rate, unsigned long parent_rate)
                return ISPTCTRL_CTRL_DIV_BYPASS;
        }
 
+       if (*rate == 0)
+               *rate = 1;
+
        divider = DIV_ROUND_CLOSEST(parent_rate, *rate);
        if (divider >= ISPTCTRL_CTRL_DIV_BYPASS)
                divider = ISPTCTRL_CTRL_DIV_BYPASS - 1;