video: tegra: host: dla: check buffer count per task

To avoid possible buffer overflow, add check for max number of buffers
count per task. Min buffer check count was already present.

Bug 1806862

CID 38902

Change-Id: I48ef974ed8cbc0972a758b79fc3c525aed2b8478
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-on: http://git-master/r/1281988
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
This commit is contained in:
Shridhar Rasal
2017-01-09 11:26:34 +05:30
committed by Laxman Dewangan
parent bf1ef90457
commit 206d951aa1
2 changed files with 9 additions and 2 deletions

View File

@@ -48,6 +48,11 @@
*/
#define MAX_NVDLA_TASK_COUNT 32
/**
* Maximum number of buffers per task
*/
#define MAX_NVDLA_PIN_BUFFERS 64
/**
* Trace Buffer Size
*/

View File

@@ -108,7 +108,8 @@ static int nvdla_pin(struct nvdla_private *priv, void *arg)
}
count = buf_list->num_buffers;
if (count == 0 || !buf_list->buffers) {
if (count == 0 || count > MAX_NVDLA_PIN_BUFFERS ||
!buf_list->buffers) {
nvdla_dbg_err(pdev, "Inval cnt arg for pin\n");
err = -EINVAL;
goto fail_to_get_val_cnt;
@@ -150,7 +151,8 @@ static int nvdla_unpin(struct nvdla_private *priv, void *arg)
}
count = buf_list->num_buffers;
if (count == 0 || !buf_list->buffers) {
if (count == 0 || count > MAX_NVDLA_PIN_BUFFERS ||
!buf_list->buffers) {
nvdla_dbg_err(pdev, "Inval count argument for unpin\n");
err = -EINVAL;
goto fail_to_get_val_cnt;