Commit a7fcc0edd4884b73a178bbab4a55ccac62875295
1 parent
14cf24b51e
Exists in
smarc_8mm_imx_4.14.98_2.0.0_ga
and in
4 other branches
MLK-20208-4 mxc IPUv3: disp: Avoid division by zero in ipu_init_sync_panel()
To avoid potential division by zero in ipu_init_sync_panel(), let's check the rounded_pixel_clk rate prior to that. Detected by CoverityScan, CID#56278 ("Division or modulo by zero") Signed-off-by: Liu Ying <victor.liu@nxp.com> (cherry picked from commit 1523150b71f1aa0610f61ea47a9f3bdbcda92522)
Showing 1 changed file with 4 additions and 0 deletions Side-by-side Diff
drivers/mxc/ipu3/ipu_disp.c
... | ... | @@ -1159,6 +1159,10 @@ |
1159 | 1159 | } |
1160 | 1160 | } |
1161 | 1161 | rounded_pixel_clk = clk_round_rate(ipu->pixel_clk[disp], pixel_clk); |
1162 | + if (rounded_pixel_clk == 0) { | |
1163 | + dev_err(ipu->dev, "rounded pixel clock should not be zero\n"); | |
1164 | + return -EINVAL; | |
1165 | + } | |
1162 | 1166 | dev_dbg(ipu->dev, "round pixel clk:%d\n", rounded_pixel_clk); |
1163 | 1167 | ret = clk_set_rate(ipu->pixel_clk[disp], rounded_pixel_clk); |
1164 | 1168 | if (ret) { |