From 601e1d16240cbe24c6d4fa72c6afacfbde13022e Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Thu, 22 Sep 2011 15:37:17 +0300 Subject: video: tegra: host: Check for allocation failures Adds checks for memory allocation failures, and proper propagation of error conditions. Adds clearing of pointers after free or unpin has been called to catch use after free. Bug 877551 Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/54027 Reviewed-by: Antti Miettinen Reviewed-by: Hiroshi Doyu Reviewed-by: Scott Williams Reviewed-by: Krishna Reddy Tested-by: Gerrit_Virtual_Submit (cherry picked from commit bfbf2766d11a5f85781532ddce3a87b7ae762ba3) Change-Id: I04171ee5db6a42bb1689221d4f80d5f3d35e7399 Reviewed-on: http://git-master/r/57462 Rebase-Id: Rc9f43312c8b818869d746f4b73700d8b56e4569d --- drivers/video/tegra/host/nvhost_syncpt.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers/video/tegra/host/nvhost_syncpt.c') diff --git a/drivers/video/tegra/host/nvhost_syncpt.c b/drivers/video/tegra/host/nvhost_syncpt.c index 3d2ec61e07a0..1c63b69fb294 100644 --- a/drivers/video/tegra/host/nvhost_syncpt.c +++ b/drivers/video/tegra/host/nvhost_syncpt.c @@ -111,6 +111,7 @@ int nvhost_syncpt_wait_timeout(struct nvhost_syncpt *sp, u32 id, { DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); void *ref; + void *waiter; int err = 0; if (value) @@ -150,8 +151,16 @@ int nvhost_syncpt_wait_timeout(struct nvhost_syncpt *sp, u32 id, } /* schedule a wakeup when the syncpoint value is reached */ + waiter = nvhost_intr_alloc_waiter(); + if (!waiter) { + err = -ENOMEM; + goto done; + } + err = nvhost_intr_add_action(&(syncpt_to_dev(sp)->intr), id, thresh, - NVHOST_INTR_ACTION_WAKEUP_INTERRUPTIBLE, &wq, &ref); + NVHOST_INTR_ACTION_WAKEUP_INTERRUPTIBLE, &wq, + waiter, + &ref); if (err) goto done; -- cgit v1.2.3