Commit 78741306fd0df0d5fff89cd0c8f89849d43e878e

Authored by Liu Ying
1 parent a8452e16eb

MLK-20208-2 mxc IPUv3: device: Avoid potential out of bounds array access

To avoid potential out of bounds array access on tbl->used[][],
let's check the tsk->ipu_id prior to that.  Based on the context,
this is what we can do to make the coverity happy.

Detected by CoverityScan, CID#17689 ("Derefernece before null check")

Signed-off-by: Liu Ying <victor.liu@nxp.com>
(cherry picked from commit f5dcf709c54da8e64eb84f1dd7a4452ad8d942cf)

Showing 1 changed file with 7 additions and 0 deletions Side-by-side Diff

drivers/mxc/ipu3/ipu_device.c
... ... @@ -1389,6 +1389,13 @@
1389 1389 }
1390 1390 }
1391 1391  
  1392 + if (tsk->ipu_id != 0 && tsk->ipu_id != 1) {
  1393 + dev_err(tsk->dev,
  1394 + "%s:invalid ipu id, no:0x%x, rel_vdoa:%d, rel_ipu:%d\n",
  1395 + __func__, tsk->task_no, rel_vdoa, rel_ipu);
  1396 + goto out;
  1397 + }
  1398 +
1392 1399 tbl->used[tsk->ipu_id][tsk->task_id - 1] = 0;
1393 1400 rel_ipu = 1;
1394 1401 ret = atomic_inc_return(&tsk->res_free);